Page 1 of 1

8bit color information regardless of ImageMagick QuantumDept

Posted: 2014-07-09T12:04:23-07:00
by TabascoSauce
Hello all,

I'm using Magick++ in a project to load a image, grayscale the image, then pass pixel color/intensity info into VLfeats' mser functions. Problem is that the VLFeat requires what is basically a uint8 array (vl_mser_pix if you're familiar) of pixel color. The code needs to compile and run on any machine regardless of what QuantumDepth installation there is

Here is the general idea of what I'm trying to do

Code: Select all

#include <Magick++.h>
#include "vlmser.h"

int main()
	Magick::Image myImg;

	//Load Image, get pixels"Completely_White_Image.png");
	Magick::PixelPacket *magickPix = myImg.getPixels(0,0,myImg.columns(),myImg.rows());

	//pixel array for VLFeat function
	vl_mser_pix vlPix[myImg.columns() * myImg.rows()]; //vl_mser_pix is essentially unit8
	//Copy magickPix into vlPix 
        [b]This is where I need help[/b]
So, back to the issue, I apparently have ImageMagick with QuantumDepth = 16 installed, so,for example, if I look at magickPix[1].red of Completely_White_Image.png I get a 16bit number (65535 in this case) even though Completely_White_Image.png had 8bit/channel color to begin with. I need to get the 8 bit
'equivalent' of this number. I know I could do something like multiply it by 256/65536 and round the result to do this, but this code needs to compile and run properly on any system. If my buddy wants to compile this with QuantumnDepth=8, that conversion factor would need to be changed manually, which I don't want to deal with.

Thank you for your help! Sorry if this is a really stupid question, until now I've only done image analysis in Matlab

Re: 8bit color information regardless of ImageMagick Quantum

Posted: 2014-07-09T12:20:10-07:00
by fmw42
I would think there would be the equivalent of the command line -depth 8. Sorry, I do not use Magick++