http://imagej.273.s1.nabble.com/Using-setColor-r-g-b-to-pseudocolor-Bayer-Raw-Image-tp5001221p5001248.html
> The part I am not sure about is how to have both images simultaneously open
> to the RGB image.
So you want to loop over the pixels of the source and destination image using getPixel and setPixel? I believe you would need to call selectImage or selectWindow to swap the image context back and forth:
Activates the image with the specified ID (a negative number). If id is greater than zero, activates the idth image listed in the Window menu. The id
can also be an image title (a string).
The problem with this technique that swapping the selected image back & forth for every pixel would be extremely flickery and slow. The getPixel and setPixel methods work very well for in-place image conversions.
Perhaps real IJ macro experts know of a more subtle way to swap the image context or you could store the pixel values in array variables. Most macros that tackle this problem such as Michael's on that other recent thread take a higher level approach, calling commands and plugins to duplicate, translate offsets, and combine. If you want to manipulate the pixels yourself a Java plugin might work better.
> To All,
>
> Been thinking about this some more and would like to run an idea past more
> experienced folks. I'm not familiar enough with ImageJ macros to know if
> this idea is possible. Feedback on this proposed, alternate method would be
> appreciated:
>
> 1. Create a new, "empty" 8-bit RGB image of exactly the same width and
> height (in pixels) as my Bayer Raw image and save it as some name, like
> maybe EmptyRGB.tiff or EmptyRGB.jpg
>
> 2 Run a macro in which I:
> 2a. Open my 16-bit, Bayer Raw image which has only a single pixel
> intensity value at each pixel location.
> 2b. Open my 8-bit, EmptyRGB.Tiff image which has three values per pixel,
> one r, one g and one b.
>
> 3. With both of these images simultaneously open.
>
> 4. Use a "for/next type" loop to read the single pixel value in the Bayer
> Raw image (to a variable) starting at location (0,0)
>
> 5. Use this variable in an algorithm (similar to a LUT) to select rgb
> values for a specific color (for example 255, 0, 0 for Red). (Note: I think
> I can handle this part)
>
> 6. Then somehow (setColor(r,g,b)?) insert these selected rgb values into
> the newly created, "empty" 8-bit RGB image at location (0,0)
>
> 7. Repeat this loop until all the pixel locations in the 16-bit Bayer Raw
> image have been used to psuedo-color all the corresponding locations in the
> 8-bit RGB image.
>
> 8. Then save the pseudo-colored 8-bit RGB image as something like,
> BayerColored.Tiff
>
> This approach sort of uses the Bayer Raw file as if it is an array of
> values, but it's actually just a 16-bit image file. It's probably a typical
> novice's, brute force approach that could be more elegantly done by a more
> experienced person, if it can work at all. Hopefully my description conveys
> the concept.
>
> I think I can easily create the "empty" 8-bit RGB file of the correct
> dimensions by just using DCRaw to convert a RAW file from the same camera
> into an ordinary, demosaiced and interpolated RGB file. As preparation I
> might even create a macro to change all the pixels in this empty file to
> black (0,0,0) or some other color by using setColor(r,g,b) so it doesn't
> contain any real image's data.
>
> So, is this approach possible? If so, any clues about how actually do it?
> The part I am not sure about is how to have both images simultaneously open
> and then go back and forth between reading the Bayer Raw image pixel,
> selecting the rgb values with my algorithm, and writing the algorithm result
> to the RGB image.
>
> I look forward to comments and suggestions.
>
> Daddymoen
>
>
>
> --
> View this message in context:
http://imagej.1557.n6.nabble.com/Using-setColor-r-g-b-to-pseudocolor-Bayer-Raw-Image-tp5001221p5001235.html> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html