The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
cam
Posts: 12 Joined: 2013-11-29T23:24:10-07:00
Authentication code: 6789
Contact:
Post
by cam » 2013-11-29T23:38:00-07:00
Hello,
This is my first time with ImageMagick. I read a 24bit BMP file (8 bits per channel) and when i iterate pixel by pixel the pixels are 16bits per channel. What is happening?
this is my code:
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <wand/MagickWand.h>
#include <string.h>
int main(int argc,char **argv)
{
MagickWand *imagen, *imagen_salida;
PixelIterator *iterator;
imagen = NewMagickWand();
MagickReadImage(imagen,argv[1]);
PixelWand **pixels;
iterator = NewPixelIterator(imagen);
MagickPixelPacket pixel;
///////////
register ssize_t x;
size_t width;
ssize_t y;
///////////
//******************ITERACION PIXEL POR PIXEL***********************
for (y=0; y < (ssize_t) MagickGetImageHeight(imagen); y++)
{
pixels = PixelGetNextIteratorRow(iterator,&width);
if (pixels == (PixelWand **) NULL) break;
for (x=0; x < (ssize_t) width; x++)
{
PixelGetMagickColor(pixels[x],&pixel);
pixel.red = 65535 - pixel.red;
pixel.green = 65535 - pixel.green;
pixel.blue = 65535 - pixel.blue;
//pixel.index = SigmoidalContrast(pixel.index);
//printf("\nr: %g", pixel.red);
PixelSetMagickColor(pixels[x],&pixel);
}
(void) PixelSyncIterator(iterator);
}
//******************************************************************
/* Write the image then destroy it. */
MagickWriteImages(imagen,argv[2],MagickTrue);
imagen = DestroyMagickWand(imagen);
iterator = DestroyPixelIterator(iterator);
MagickWandTerminus();
return 0;
}
If i read a 24 bits image i think i should edit it like a 24 bits image. what can i do?
Thanks a lot!.
cam
Posts: 12 Joined: 2013-11-29T23:24:10-07:00
Authentication code: 6789
Contact:
Post
by cam » 2013-11-30T10:06:16-07:00
Hi,
and how can i change my MagicWand version to Q8? Any idea?
Thank you very much
magick
Site Admin
Posts: 11064 Joined: 2003-05-31T11:32:55-07:00
Post
by magick » 2013-11-30T10:11:06-07:00
Set the image depth to 8 before you write it. That should fix the problem, the Q8 version of ImageMagick is not required.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:
Post
by fmw42 » 2013-11-30T11:19:11-07:00
convert image ...processing... -depth 8 result
cam
Posts: 12 Joined: 2013-11-29T23:24:10-07:00
Authentication code: 6789
Contact:
Post
by cam » 2013-11-30T13:08:33-07:00
The image that i open is 24bits and the image that my code writes in disk is 24bits, but in pixel iterators i treat the image as it was 48bits (16bits per channel).
I want to treat the image as 24bits (0-255 for each channel, not 0-65535 for each channel) image.
Thank you very much for your time.
dlemstra
Posts: 1570 Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:
Post
by dlemstra » 2013-11-30T13:41:30-07:00
Can you explain why it is a problem that the pixel iterator has 16 bits per channel? And instead of modifying the pixels by yourself you could also call the MagickNegateImage method that does the same as what you are trying to do.
cam
Posts: 12 Joined: 2013-11-29T23:24:10-07:00
Authentication code: 6789
Contact:
Post
by cam » 2013-12-01T18:39:50-07:00
Hi,
I reinstalled imagemagick with Q8 option and now every image has 8bits per channel with this command in the instalation from console:
Code: Select all
./configure --with-quantum-depth=8
Thanks a lot.
Users browsing this forum: No registered users and 9 guests