Use a LUT as an Array

After seeing the movie “Concussion” I decided it’s probably best to stop beating my head agains the wall and ask for help again. Still not able to color an RGB image from an array. I’ve triedeverything I can find, none of it works.

The code below is arranged as a test ofcoloring from an array. As shown below it works fine, the array is not used and “setPixel=hexcolor;” correctly colors the RGB image yellow (hex value 0xfffff00)

But, if I change two lines, commenting one out and adding one, the image changes to black even though the array gives the same hex color value.

Am I dealing with some default value that takes over coloring? Even though the hex color values are identical are they somehow different because one comes from an array?

Feels better to stop beating my head against the wall.

Daddymoen

// Coloring from an Array demoe
title = "AA-RGB-test";
newImage(title, "RGB", 30, 50, 1); // type "RGB"; depth 1 
id = getImageID();
h = getHeight();
w = getWidth();
print(title, id,h,w)
Ahex = newArray(h);
  for (x = 0; x < (w+1); x++) {
  	Ahex[x] = "0xffff00";
 //Array.print(Ahex);
  }	
h=50;
w=30;
    hexcolor = 0xffff00;  // comment this line out tko test array coloring
  for (i=0; i<(w); i++)  {
 	for (j=0; j<(h);  j+=1)  {
//    hexcolor = Ahex[i];      // remove the"//" to the left of "hexcolor" to test array coloring
//   print(i, j, hexcolor);  // test Array (Ahex) content.
  		setPixel(i, j, hexcolor );//put 0x in front of hex number
       }
 }
 //  Array.show(Ahex);
  updateDisplay();
 saveAs("jpg");
//saveAs("tif");
close();

Daddymoen,

sorry, but in general your code is messy.

But to your specific problem:
Why do you store a string in the array and not a number?
Use
Ahex = 0xffff00;
instead.

How comes that I am able to find this flaw?
Again, your problem has nothing to do with image processing…

HTH

Herbie

He is posting in the Development category, so there is no requirement that that the problem be specific to image processing—only related to ImageJ in some fashion. Which it is.

1 Like

Guess I haven’t shared much about the image analysis and processing side of my project yet, since it’s come up perhaps I should. My project is all about a specific type of image processing. The macro I am working on is intended to make a normally invisible “realm” visible. I call it, Digital Phantom Leaf Photography.

Essentially, a portion of a fresh picked leaf that is roughly the size of a dime is removed. The resulting hole along with some of the surrounding leaf is then photographed against an extremely uniform white background. This is the image I work with.

There is some controversial evidence from researchers in the past suggesting that when the physical portion of a leaf is removed something called a “nonphysical”,or “phantom” leaf continues to exist for some amount of time in the empty space. Past researchers using Kirlian (high voltage, corona discharge photography) claimed that physical world leaf structures, like leaf veins, could be seen in their phantom leaf images.

As a fellow with curiosity, and being a retired engineer with time on my hands, I’ve been working off and on for a few years at developing image processing tools to create a simplified, safer form of the old high voltage, corona discharge phantom leaf photography.

The theory is that light passing through hole in the leaf will interact with whatever these phantom leaf structures are. And, that the light intensity pattern falling on a digital camera’s sensor will be affected enough to be detectable as variations in light intensity.

To make these light intensity variations visible every shoe-string-budget effort is made to limit camera sensor noise, and to provide as close as possible to a perfectly uniform white background when taking the pictures.

But the most critical part of the process, the part that makes the invisible, visible, is the image processing and pseudocoloring to be done by the macro I am developing. Like the TV weatherman’s pseudocolored maps that show temperature variations, variations in light intensity can be pseudocolored to show what can’t be seen with the naked eye in my images. My present macro project is to pseudocolor light intensity variation in my digital phantom leaf images. Eventually I want this macro to become a stand alone program I can give to anyone with the curiosity to discover the truth about phantom leaves, and to ponder the implications of their existence. Ultimately, I’d like to see scientists doing this kind of exploration and discovery.

There’s a detailed description of the project on my website for anyone that’s interested at:

http://afterlife-knowledge.com/phanpics.html

At the bottom of that page are a couple of Digital Phantom Leaf photographs I created years ago using the old Filtermeister plugin software and lossy jpg image files. These images strongly suggest the existence of phantom leaf vein structures.

Some time after I originally posed those photos on my website a Frenchman who writes image processing software, in Delphi, replicated my work. He used the description on my website of what I had done to that point to create an image processing program. His program is able to show about the same level, or a little better, phantom vein structures in his .jpg images. On my website you can scroll down to see some of his images at:

http://afterlife-knowledge.com/cgi-bin/yabb/YaBB.cgi?num=1332171581/0

So, there you have it. What I am working on is an image processing macro. With the help of folks at this Forum I’m making progress toward my goal. Success at this point means better control of all the image processing factors to get higher resolution, more definitive images.

Thanks again for all your help.

Daddymoen

Still having trouble coloring my final image. Herbie’s advice works, but I can’t find a way to use it in my case:

Herbie said: “But to your specific problem:
Why do you store a string in the array and not a number?
Use Ahex = 0xffff00; instead.”

I ran a test on my macro alternating two different hexadecimal colors,
Ahex = 0x7CFC00 and Ahex = 0xffff00 and setPixel(Ahex) colored my final image properly.

The Problem:

Earlier in my macro I convert the R, G, B values of a standard LUT file to single, six digit, hexadecimal numbers and store them in an array. For the sake of discussion let’s say that the conversion yields a hexadecimal number, ffff00. Note that 0x do not precede the hex number which would make it an eight digit hex number, 0xffff00.

But the macro language command setPixel(hexadecimal) appears to require that the “hexadecimal” in that command be entered as 0xffff00 instead of ffff00. That’s what my alternating hex number test shows

In order to get the hexadecimal value into the proper format I use:

hex = “0x” + r + g + b;

The added string, “0x”, appears to be the problem. The “0x” is a string and not a number. When I store “hex” in the Ahex() array it looks like it is being stored as a string instead of a number. Since setPixel() requires a number and not a string, when trying to color my final image setPixel() is fed a string, pukes, and colors the pixel black.

I’ve tried converting the string “hex” to a number using parseInt() to no avail. I’ve search for a way to get setPixel() to accept a six digit hexadecimal, nada. I’ve tried to figure out a way to store a hex like 0x7CFC00 as a number, nada, I’ve spent hours trying to find a way around the problem without finding a solution.

Any ideas to get around this would be appreciated.

Daddymoen

Thank you for explaining your project! It was an interesting read.

I am afraid I must disagree—it is an optical illusion. Qualitative image analysis—e.g., judging phenomena by eye—is sometimes misleading, especially when color is involved. See e.g. Spirals and Adelson’s Squares examples, available from Fiji’s “Open Samples” menu.

If you want to convince yourself: cover up the remaining leaf area with your hands, staring at the noise alone. The supposed vein structures fade. You can even convince yourself they run in various other directions if you like.

In order to measure phantom leaf phenomena scientifically, at minimum, you should attempt to measure the correlation between the before and after photographs in the removed area. What you are trying to do here is a form of colocalization analysis, so reading the Colocalization page of the ImageJ wiki would probably be helpful for your project.

1 Like

Daddymoen,

I think we should differentiate between your hobby project and your problems with the syntax of the IJ-macro language.

re 1:
I agree with Curtis that the scientific background of your endeavor appears doubtable; but of course you are free to do what you like, at least as long as it doesn’t harm others.

re 2:
You know what I did to find the solution of your problem?
I searched the “Built-in Macro Functions”-manual for the word “Hex”. Here is what I’ve found:

parseInt(string, radix)
Converts string to an integer and returns it. The optional second argument (radix) specifies the base of the number contained in the string.The radix must be an integer between 2 and 36. For radixes above 10, the letters of the alphabet indicate numerals greater than 9. Set radix to 16 to parse hexadecimal numbers.Returns NaN if the string cannot be converted into a integer. For examples, seeParseFloatIntExamples.”

You could have done that too – no?

print("0xffff00");
print(parseInt("ffff00",16));

HTH

Herbie

Ctrueden,

I agree with your assessment that this all may be optical illusion, or what science calls apophenia. My experience investigating phantom leaf phenomenon suggests it is also possible that some form of nonphysical structures do exist. To answer the most basic question,“Do these nonphysical structures exist?,” I as an engineer favor investigation and experimentation. That approach requires tools with which to observe and measure this supposed phenomenon. That is the thrust of my macro writing effort, to create improved tools for investigation.

The images at my website were made with a very crude pseudocoloring technique performed upon lossy, data corrupting, .jpg files. It’s possible the phantom vein structures I think I see in those images are just artifacts of jpg data loss, “pretty picture” data massage, and the crude pseudocoloring technique I was using, coupled to apophenia.

The macros and image capture improvements I am working on are intended to improve image resolution, reduce noise and eliminate artifacts. I feel my work to date has only scratched a surface. Perhaps improved investigative tools will lead to a conclusion regarding the reality or fantasy of the phenomenon.

Daddymoen

Herbie,

I also did the “hex” search of the Built in Macro functions, it’s how I found parseInt(string) and read about parseInt(string, radix). But I think my lack of macro writing experience and some basic knowledge and understanding means I sometimes don’t see how to apply the answer that is right in front of my face. So, I spend 10 to16 hours a day sometimes trying to figure out something a more experienced programmer would immediately see a solution to. When I have exhausted every approach I can think of I post here for advice.

I understand that my novice level abilities can be trying, and I greatly appreciate the advice, direction and solutions you and others here provide.

Herbie, thank you for your patience and assistance.

Daddymoen

Daddymoen,

may I suggest that ,instead of sometimes spending “10 to16 hours a day […] trying to figure out something […]”, you could simply have a look at the hundreds of example macros, especially if they are recommended like in the latest case:

parseInt(string, radix)
[…] For examples, see ParseFloatIntExamples.”

There you find, beside other examples:
print("\"F\": "+parseInt("F", 16));

Hope this speeds up your work

Herbie