how to perform all grayscale image operation on rgb image? - image-processing

I know ,how to perform Operation like brightness,contrast etc on grayscale image.
I want to know how to perform all this operation on RGB color image?

Related

Converting colored image to grayscale

I am working on processing images that consists of colors that have the same grayscale. In other words, each image is colored with random colors that have the same gray value.
When I converted the image using (rgb2grey() from skimage or cv2.cvtColor() from OpenCV), the resulted image has only one gray value (or slightly difference gray values (unperceivable by human eyes). Therefore, the resulted image details unrecognizable.
My questions are:
What are the best way to do before converting these images to grayscale ones? (Please note the colors of these images are not fixed)
Are there any color combinations for which the color-gray conversion algorithms won't work?
How about using YCbCr?
Y is intensity, Cb is the blue component relative to the green component and Cr is the red component relative to the green component.
So I think YCbCr can differentiate between multiple pixels with same grayscale value.

Converting Grayscale Images to Colormap in Swift/iOS?

I have a 512x512 grayscale image (or MultiArray) which is the output of a CoreML depth estimation model.
In Python, one can use Matplotlib or other packages to visualise grayscale images in different colormaps, like so:
Grayscale
Magma
[Images from https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html]
I was wondering if there was any way to take said output and present it as a cmap in Swift/iOS?
If you make the model output an image, you get a CVPixelBuffer object. This is easy enough to draw on the screen by converting it to a CIImage and then a CGImage.
If you want to draw it with a colormap, you'll have to replace each of the grayscale values with a color manually. One way to do this is to output an MLMultiArray and loop through each of the output values, and use a lookup table for the colors. A quicker way is to do this in a Metal compute shader.

How to store the DCT values in an image?

My initial task is to take a grayscale image in java, perform DCT over it (using block size 8X8) , write the DCT image. Then take the DCT image and then perform the inverse DCT over it to get back the original image.
Now the problem am facing here is , when each of the block undergoes DCT, the operation will result in many negative values and the values out of the grayscale range (for eg.,260).
How to write a grayscale image with negative values and the values out of the range? Is there any other operation need to be performed before writing the image so that all the values fall under the 0-255 range?

Changing color space in opencv without changing color of the image

I am working on a project where I read an image load the data into Mat data type. Then, I do some operations on it.
All my operations are done assuming the color space is RGB (BGR as opencv stores in that way). Everything is working fine. I was doing experiment on converting the output image to YUV format. But when I transform the output image from BGR2YUV using the following command I found that the resulting image color is changed completely.
cvtColor(img,out,CV_RGB2YCrCb);
For example, my output RGB image is green. When I convert this to YUV format and show the resulting image I found it blue and NOT green.
I want a way to convert so that the output also become green.
How can I change the color space from RGB to YUV without changing the colors in the image?
The colors of the image have not changed, just the coding.
If you convert the color to YUV, then use imshow(), it assumes the color is still RGB so it displays it incorrectly.
If you have a YUV image and you want to display it, you first have to convert it back to RGB.
When you ask "How can I change the color space from RGB to YUV without changing the colors in the image?" you are essentially saying "how can I do color conversion without doing color conversion?" which of course is impossible.

Histogram equalization upon RGB images? RGB ouput possible?

I was writing code for histogram equalization upon RGB images?
It was suggested not performing equalization operation against R-G-B channels respectively.
So I first converted RGB to YUV color space and then performed equalization on Y channel (only), leaving U and V channel as what they were, converted altered Y channel with original U and V channels back to RGB color space.
The (RGB) resulting output was not ideal, while the gray scale ouput generated from Y channel only was quite acceptable.
My question is, Is it possible to get a full color RGB equalized ouput? And how? Should I perform equalization operation on U&V channel as well?

Resources