Extract color from location on image

I would like to try and extract a color value (don't care what format) from a specific location on an image.
Here is the image I am using; http://www.sws.bom.gov.au/Images/HF%20Systems/Global%20HF/HAP%20Charts/San%20Francisco.gif
It looks like this;


I am trying to read the color value once an hour for the location of New York and another value for Phoenix Arizona.

I have looked very closely at the nodes coco and vibrant, they come close, but neither seem to do what I need.

My Node-RED is running on a Windows PC if that matters.

I am currently manually switching the tuned frequency of a radio via the Node-RED dashboard buttons, but I would like to automate it based on the propagation map.

Thanks for your help.

Assuming your image isn't a simple bitmap in a buffer (where you could calculate the offset to the pixel) you can use node-red-contrib-image-tools.

If you can have the X & Y position, you can get the colour using node-red-contrib-image-tools

Inject (X&Y) - image node (return image) - function node - debug

Function. ..

msg.image = msg.payload;
var x=msg.pixel.x;
var y=msg.pixel.y;
msg.payload = msg.image.getPixelColor(x, y); // returns the colour of that pixel e.g. 0xFFFFFFFF
return msg;

EDIT...

Example...

image

Flow...

[{"id":"a1dc1fe1.0cbe5","type":"inject","z":"1fbcaf1e.e73671","name":"{\"x\":250,\"y\":250}","topic":"","payload":"{\"x\":250,\"y\":250}","payloadType":"json","repeat":"","crontab":"0 0-22 * * *","once":false,"onceDelay":0.1,"x":150,"y":160,"wires":[["55c59618.0adb68"]]},{"id":"2377f26a.d9206e","type":"jimp-image","z":"1fbcaf1e.e73671","name":"","data":"http://www.sws.bom.gov.au/Images/HF%20Systems/Global%20HF/HAP%20Charts/San%20Francisco.gif","dataType":"str","ret":"img","parameter1":"img.png","parameter1Type":"str","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":470,"y":160,"wires":[["b8a4eed2.52b58"]]},{"id":"b8a4eed2.52b58","type":"function","z":"1fbcaf1e.e73671","name":"","func":"msg.image = msg.payload;\nvar x=msg.pixel.x;\nvar y=msg.pixel.y;\nmsg.payload = msg.image.getPixelColor(x, y); // returns the colour of that pixel e.g. 0xFFFFFFFF\nreturn msg;\n","outputs":1,"noerr":0,"x":590,"y":160,"wires":[["5624b47d.dbf37c"]]},{"id":"55c59618.0adb68","type":"change","z":"1fbcaf1e.e73671","name":"","rules":[{"t":"set","p":"pixel","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":160,"wires":[["2377f26a.d9206e"]]},{"id":"85cd529d.73f19","type":"debug","z":"1fbcaf1e.e73671","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":160,"wires":[]},{"id":"5624b47d.dbf37c","type":"image viewer","z":"1fbcaf1e.e73671","name":"","width":"300","data":"image","dataType":"msg","x":710,"y":160,"wires":[["85cd529d.73f19"]]}]
4 Likes

Steve, great job!!!

2 Likes

@thebaldgeek
Hi, just would like to ask you what to be alerted on. I mean Solar X-Ray Flux, what is good, what is bad? The colors, which are bad and which are good? Or is this map just showing the actual frequency of the x-ray radiation?

@Steve-Mcl How can I even start to say thanks!
The quality of the node and the quality of your post to my question is just amazing.

Interestingly it took me about 2 hours to actually get it working - hopefully those following along will not fall into the same trap I did.... Finding the X,Y coordinates of each part of the image was the time sink.
There are a few online tools to help, use them, unless you really trust your image editing tools.
I had to get the color value from each of the main frequencies on the scale and then compare them to the color at each of my locations.
I have the basic code working, now for the changing of the radio frequency..... This is just too much fun!

@krambriw I am not using to alert me. I am using it to set the radio frequency so that I can get the signal from the location I want.
The colors are not good or bad, they each represent a frequency band.
As the solar radiation changes the ionosphere, the radio 'skip' distance will change and you will no longer hear the distant station. In your image, you need yellow, low frequency, to hear signals close to Stockholm.
As the day passes, that patch of yellow will move and your radio will fade out for example.

I will soon be able to 'read' the map in Node-RED and automatically tune my radio to always get the distant station.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.