Posted by
Michael Schmid on
Dec 20, 2012; 9:35am
URL: http://imagej.273.s1.nabble.com/Using-setColor-r-g-b-to-pseudocolor-Bayer-Raw-Image-tp5001221p5001226.html
Hi Dadymoen,
you could try the de-Bayer macro from my previous post (7-Aug-2012):
id = getImageID();
makeColorChannel("R", 0, -1);
selectImage(id);
makeColorChannel("G1", 0, 0);
selectImage(id);
makeColorChannel("G2", -1, -1);
selectImage(id);
makeColorChannel("B", -1, 0);
function makeColorChannel(name, dx, dy) {
slices = nSlices();
newWidth = getWidth()/2;
newHeight = getHeight()/2;
run("Duplicate...", "title=&name duplicate range=1-&slices");
run("Translate...", "x=&dx y=&dy interpolation=None stack");
run("Size...", "width=&newWidth height=&newHeight depth=&slices interpolation=None");
}
It will give you 4 channels. If you are satisfied with the small image size (1/2 of the original in x and y), use the Image Calculator to blend the two G(reen) channels, and then combine everything into a Stack (ImageJ has not 'real' RGB image with more than 8 bits per channel): Image>Stacks>Images to Stacks, then Image>Hyperstacks>Stack to Hyperstack, with 3 channels and 'Display Mode'='Composite'.
The result will look like an RGB image, but it's actually three 16-bit images. You can get a 24-bit RGB image (8 bits per channel) via Image>Type>RGB Color.
If you want to recover the original size, the makeColorChannel function could be easily extended to do a 'Size' back to the old size (but with interpolation), and than the translation back, again with interpolation of your choice (bilinear or bicubic). Again, combine to a Stack and create a 'Composite' Hyperstack from it.
Michael
________________________________________________________________
On Dec 19, 2012, at 23:06, Daddymoen wrote:
> To All,
>
> I'm just learning ImageJ macro writing and this problem has me stumped.
> I've searched the forum posts looking for clues. Hopefully a more
> experienced macro writer can point me in the right direction to find a
> solution.
>
> Using DCRaw (-v -4 -D -T filename.crw) I've converted a Camera Raw file to a
> 16-bit Tiff, Bayer Raw file. The resulting image file is not demosaiced or
> interpolated so the pixel intensity data is as close to the original camera
> sensor values as I know how to get. The 16-bit image has values in the
> range of 0 to 1023 (camera's 10-bit sensor range) with one value per pixel
> in an RGGB (2x2) pattern.
>
> I want to pseudocolor this image using a method that writes RGB values to
> each pixel location. The LUTs available have more than one pixel intensity
> value in each bin which is too coarse for my application. (In the past I've
> used an algorithm in a FilterMeister filter that worked well. But alas,
> FilterMeister is C+, ImageJ is Java, and me no speakee Java.) As an
> experiment a wrote a macro to see if I could pseudocolor the Bayer Raw image
> at all. I attempted to change all the pixels in the image to Red using the
> following code.
>
> // My first program to Color Bayer Raw Pixels
> print("This Macro Colors Bayer Raw Pixels");
> // Color all pixels Red
> for (j=0; j < getHeight();j+=1)
> { for (i = 1; i < getWidth(); i+=1)
> { setColor(255,0,0);
> }
> }
> updateDisplay();
> print("I'm Done");
>
> Needless to say if that code had worked I wouldn't be here asking for
> assistance. I assume there is something about my Bayer Raw image, my macro,
> or my lack of knowledge that won't allow my novice's
> approach to work.
>
> Is there a way to do this? Is there another approach to pseudocoloring
> 16-bit Bayer Raw images that might succeed?
>
> Open to suggestions,
>
> Daddymoen
>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html