RGB changing B value affects R and G as well.... How to solve?
I am creating a 100x100 BufferedImage, if I set R=200, G=160, B=80.. SetRGB and Write to disc using ImageIO.write, I am getting a Solid Color image alright. I can also Get the Pixel Values of the Created Image from another function without any error.
Now, I am creating another Image with the same procedure, this time I am keeping R=200, G=160.. same as above, not disturbing. But I am changing the value of blue with an integer array, say (156, 145, 24.......). I expect an Image With Red and Green Constant as the previous Image, different values for Blue. But Using my reader function to GetPixels, I have 2 problems i) Blue, is NOT retrieving the Values that I set ii) Instead being constant, R and G values are also some random(?) numbers.. (The Writer or Reader functions do not throw any errors). I am working with Java, OpenCV 2+ version, Netbeans. Any Idea what could be wrong? Thanks in advance.
we need your code, to see what you're doing. could you please edit your question, and edit the relevant part there ?
btw, BufferedImage, SetRGB, GetPixels -- none of it opencv code, so how would that be relevant here ?
If you are saving the image as a JPG or other lossy format, you could be seeing compression artifacts that result in R and G value changes. What do you mean by R and G being random values? Are they close to 200,160, but they vary by 1 or 2 levels, or do they vary a lot? Also is it possible that you are saving in one format and retrieving in another? (something as simple as RGB/BGR, or mayy RGB/YUV)
How you assign the value of blue by array? May this is the problem, and also, which flag you use during the creation of the image? CV_8U? An example code to reproduce the error is more than appreciate