Creating a color image with NSBitmapImageRep and greyscale data
Creating a color image with NSBitmapImageRep and greyscale data
- Subject: Creating a color image with NSBitmapImageRep and greyscale data
- From: Jason Horn <email@hidden>
- Date: Tue, 27 Nov 2007 19:38:11 -0500
I need to create a color image from greyscale data. This is because I
would like to display the image in false color to aid in
visualization. I have tried using the CIColorMap core image filter on
a CIImage created from a 16 bit greyscale NSBitmapImageRep, but this
does not work (you just get a modified greyscale image, not color).
Unfortunately, there is nothing in the documentation for CIColorMap
that says you can only apply this filter to a color image, but I am
assuming that that is the case. So, I though I would transform the
greyscale image data into color RGB data and create a color
NSBitmapImageRep, but this is not working either. Here's what I have:
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:width
pixelsHigh:height
bitsPerSample:16
samplesPerPixel:3
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
bytesPerRow:3840
bitsPerPixel:48];
unsigned char *bitmapData = [bitmap bitmapData];
uint16_t RGBData[921600];
int pixel, color;
int numPixels = height*width;
for (pixel=0; pixel<numPixels; pixel++) {
for (color=0; color<3; color++) {
RGBData[pixel+color] = pixels[pixel];
}
}
memcpy(bitmapData, RGBData, [bitmap bytesPerRow] * [bitmap
pixelsHigh]);
'pixels' is an array of 16 bit integers that contain the data for the
16 bit greyscale image that is 640 x 480. This code actually produces
a three mini-greyscale images inside the main image.
Does anyone know hat I'm doing wrong? Any suggestions for creating a
color image from greyscale data?
Thanks!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden