Login  Register

Re: An alternate approach to pseudocolor Bayer Raw Image?

Posted by Daddymoen on Dec 21, 2012; 6:42pm
URL: http://imagej.273.s1.nabble.com/Using-setColor-r-g-b-to-pseudocolor-Bayer-Raw-Image-tp5001221p5001255.html

Aivar,

Thank you for sharing your knowledge. Yes looping over the pixels in both the source and destination images as you describe is how I, as a novice, am able to understand the concept of a solution using macros.  I realize from your post that using macros is a kind of slow, clunky way to accomplish the task, but it points in a direction I grasp and can make some progress with.  My project would no doubt benefit from me taking the time to learn Java programming to accomplish this with plugins.  If my quick and dirty macro approach shows good evidence of making the phantom leaf structures I'm looking for visible I will probably bite the bullet and learn Java plugin programming.  Maybe the experience with macro approach will help learning that.

From your other post I understand enough about how to create an RGB image file (identical size-wise to my Bayer Raw image) to figure out the rest of the details.  

I feel like I can get back to work and make some progress again.

Thanks for that.

Daddymoen

PS: Not sure the images below will display well enough to see evidence of the phantom leaf structures I am trying to image in my project.  The first image shows a leaf before cutting out a small rectangular section.  The second image is of the same leaf after removing the rectangular section and processing the image data to pseudo color pixel intensity variation of the area where the leaf no longer physically exists.  This was done with my old FilterMeister/PhotoShop plugin method using 8-bit, lossy, JPG image files.  I think that using 16-bit Tiff images and some changes I now use in taking the pictures (that improve resolution) have a chance of yielding better results.


Digital Phantom Leaf Image
-----------------------------------
Aivar Grislis wrote
> 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.

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:

'selectImage(id)

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).
  selectWindow("name")

Activates the window with the title "name".'

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.

(Here's some one else doing this with IJ macro http://www.flickr.com/photos/hortonheardawho/7865007812/ )

Aivar
Imagination is more important than knowledge.  Albert Einstein