Is there a formula for correcting RGB in an image based on a sample within the image? - rgb

In a photo I have the following:
position 1,1: red (255,0,0)
position 1,2: green (0,255,0)
position 1,3: blue (0,0,255)
position 1,4: white (255,255,255)
position 1,5: black (0,0,0)
If in the photo these values come back differently than expected, for example, position 1,1 is rgb(144, 20, 10) and I know it should be rgb(255,0,0) then...
How do I calculate how much to correct my red values in the image
Would I use a feature such as Color Balance in an editor to apply the corrections

Related

Echarts line cannot be displayed

Echarts Version:4.9.0
There are two lines and four X axes in this picture. The yellow line corresponds to a true hidden X axis and a false displayed X axis above.And the green line corresponds to the lower part.More data on the green line than on the yellow line,but the green line can only display as much data as the yellow line.The last part of the data on the green line cannot be displayed.I want both lines to be fully displayed.Can someone help me?
I read the Echatrsdocuments, but couldn't find a good way.

how to pick pixel colour from picture GTK 3

I have image in pixbuf and viewed in GtkImage widget, Need Get pixel coordinates from cursor position and get that pixel value from the pixbuf.
user will move mouse over the image and pick any colour from that picture, i dont know what to use or best approach to pick colour from picture displayed in window

Get DCT values from image

I am pretty new to everything related to image processing so please have that in mind. I have been trying to understand how to get the DCT dc coefficients of luminance blocks from an image. I have read some stuf from here https://en.wikipedia.org/wiki/Discrete_cosine_transform#DCT-I and other sources but i am not sure i got it. So if we have an RGB image and we can get all the red, green, blue values from it how can we use them to get the DCT(m,n) where m,n the position of the each pixel?

How to fill area between 2 polylines in WPF with condition

I am developing a charting application in which there are 2 polylines, say Polyline A (shown as red colour line in below image) and Polyline B (shown as blue colour line in below image).
There can be 2 conditions in the chart:
When the red line intersects the blue line from above and then stays below the blue line, I want to fill that area with some color.
When the red line intersects the blue line from below and then stays above the blue line, I want to fill that area with some other color.
Without ever having done this, i could imagine that you might be able to do what you want without much mathematics by filling a Path and setting its Clip in an appropriate way.
Let's say you fill the entire area below the red line with green. Therefore you would set up a filled Path whose Data geometry is a closed polygon consisting of all the points of the red line plus the two lower corner points of the viewport. On that Path you would set the Clip property to another closed polygon geometry, which would consist of all the points from the blue line plus the two upper points of the viewport. For the red fill you would do the same again, but with exchanged polylines.
The straightforward approach would of course be to find the intersection points, determine the direction of the intersection, create closed polygons from the upper and lower line points plus the appropriate intersection points and fill these polygons according to the intersection direction.
Good luck!

Making a color completely transparent in OpenCV

I have a basic png file with two colors in it, green and magenta. What I'm looking to do is to take all the magenta pixels and make them transparent so that I can merge the image into another image.
An example would be if I have an image file of a 2D character on a magenta background. I would remove all the magenta in the background so that it's transparent. From there I would just take the image of the character and add it as a layer in another image so it looks like the character has been placed in an environment.
Thanks in advance.
That's the code i would use,
First, load your image :
IplImage *myImage;
myImage = cvLoadImage("/path/of/your/image.jpg");
Then use a mask like this to select the color, you should refer to the documentation. In the following, I want to select a blue (don't forget that in OpenCV images are in BGR format, therefore 125,0,0 is a blue (it corresponds to the lower bound) and 255,127,127 is blue with a certain tolerance and is the upper bound.
I chose lower and upper bound with a tolerance to take all the blue of your image, but you can select whatever you want...
cvInRangeS(image,
cvScalar(125.0, 0.0, 0.0),
cvScalar(255.0, 127.0, 127.0),
mask
);
Now we have selected the mask, let's inverse it (as we don't want to keep the mask, but to remove it)
cvNot(mask, mask);
And then copy your image with the mask,
IplImage *myImageWithTransparency; //You may need to initialize it before
cvCopy(myImage,myImageWithTransparency,mask);
Hope it could help,
Please refer to the OpenCVDocumentation for further information
Here it is
Julien,

Resources