Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Program to convert image and rotate

Name: Anonymous 2012-10-21 11:50

I've been trying to make this program in c++ with opencv that converts the image to greyscale and rotates the image afterwards, but the output I get is all kinds of messed up.

I haven't been able to find what the hell I have done wrong so if any of you could help me it'd be great

http://pastebin.com/FSJKyaeU

Name: Anonymous 2012-10-21 11:58

Install GIMP.

Name: Anonymous 2012-10-21 12:29

With ImageMagick:
convert input_image.png -colorspace Gray -rotate 90 output_image.png

There's a C++ library for it, so use that if it has to be C++ for some reason.

Name: Anonymous 2012-10-21 12:32

>>2
>>3
The thing is that i'm trying to actually make a program that rotates the image by using an algorithm, and outputting it as a greyscale image.

Name: Anonymous 2012-10-21 13:00

>>4
Someone has already done it, and they've done it better than you. Be grateful: now you don't have to do any work!

Name: Anonymous 2012-10-21 13:12

>>5
I don't think you understand.
This is how I have to do it.

Name: Anonymous 2012-10-21 13:15

>>1

Check Line 22 again

Name: Anonymous 2012-10-21 13:17

>>6
The sooner you get over your obsessive-compulsive disorder, the better.

Name: Anonymous 2012-10-21 13:40

>>7
Yeah, I suspected that's where it goes wrong, but I just can't put my finger on it

Name: Anonymous 2012-10-21 17:16

>>9

if you can't see the mistake in there, then you need a break.

Name: Anonymous 2012-10-21 17:34

>>3

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char ** argv)
{
  const char * str = new char[512];
  char * d = memchr(argv[1], '.', strlen(argv[1]));
  const char * str2 = new char[512];
  memmove(str2, argv[1], d -  argv[1]);
  str2[d - argv2 + 1] = 0;
  snprintf(str, 512, "%s %s %s%s%s", "convert", argv[1], "-colorspace Gray -rotate 90", str2, "output", argv[1] + d);
  system(str);
  delete [] str; delete [] str2;
  return 0;
}

Name: >>11 2012-10-21 17:55

whoops


#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char ** argv)
{
  const char * str = new char[512];
  char * d = memchr(argv[1], '.', strlen(argv[1]));
  const char * str2 = new char[512];
  memmove(str2, argv[1], d -  argv[1]);
  str2[d - argv2 + 1] = 0;
  snprintf(str, 512, "%s %s %s%s%s", "convert", argv[1], "-colorspace Gray -rotate 90", str2, "output", argv[1] + d);
  system(str);
  delete [] str; delete [] str2;
  return 0;
}

Name: >>12 2012-10-21 17:56

whoops


#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char ** argv)
{
  char * str = malloc(512);
  char * d = memchr(argv[1], '.', strlen(argv[1]));
  char * str2 = malloc(512);
  memcpy(str2, argv[1], d -  argv[1]);
  str2[d - argv[1] + 1] = 0;
  snprintf(str, 512, "%s %s %s %s%s%s", "convert", argv[1], "-colorspace Gray -rotate 90", str2, "output", d);
  system(str);
  free(str); free(str2);
  return 0;
}

Name: Anonymous 2012-10-22 3:36

,K,¨⊃(⊂⊂¯9 ¯11)+.○¨¨∘.,/⍳¨⍴K
This converts a bitmap K into a value paired with a complex number representing the coordinates.

Name: Anonymous 2012-10-22 4:35

>>14
Now write it in Lisp.

Name: Anonymous 2012-10-22 5:02

>>14
Is that symta?

Name: Anonymous 2012-10-22 6:01

Sepples a shit.

Name: Anonymous 2012-10-22 6:48

>>15
,K,¨⊃(⊂⊂¯9 ¯11)+.○¨¨∘.,/⍳¨⍴K))))))))))))))))))))))

Name: Anonymous 2012-10-22 9:28

Paradife Loft

Name: Anonymous 2012-10-22 10:34

>>1
Just move each pixel to a x*(cos angle), y*(sin angle), then fill result pixels with closest matching rotated-neighbors. Using a simple N-linear interpolation will greatly increase rotation quality.

Name: Anonymous 2012-10-22 12:27

using namespace std;

i see  your code is off to an amazing start, op

youre going to go far

Name: Anonymous 2012-10-22 15:38

>>20
You're an idiot. That's not linear interpolation, that's nearest neighbor.

>>9
The problem is that you're truncating on lines 20 and 21. When you rotate an image the resulting coordinates are not going to fall exactly on the pixels and it's going to look like crap.

What you need to do is look up bilinear interpolation. Then, write a function that does that by taking the image and two double coordinates and gives you the value between the pixels. Use that function instead of im.at<unsigned char>.

Also, your rotation matrix is inverted.

Name: Anonymous 2012-10-22 22:12

>>22
Reading comprehension.

Don't change these.
Name: Email:
Entire Thread Thread List