8bit color information regardless of ImageMagick QuantumDept

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
TabascoSauce
Posts: 1
Joined: 2014-07-09T11:31:26-07:00
Authentication code: 6789

8bit color information regardless of ImageMagick QuantumDept

Post by TabascoSauce » 2014-07-09T12:04:23-07:00

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
	myImg.read("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

User avatar
fmw42
Posts: 25560
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: 8bit color information regardless of ImageMagick Quantum

Post by fmw42 » 2014-07-09T12:20:10-07:00

I would think there would be the equivalent of the command line -depth 8. Sorry, I do not use Magick++

Post Reply