Hi, I’m higashi.
This time, I introduce how to convert monochrome image to pseudo color image as shown below by using Python & OpenCV.
★Original Monochrome Image
★Pseudo Color Image
By changing to color image, we will be easier to recognize subtle brightness change.
This method is often adopted to experimental image.
So, let’s get started!!
How to Convert Pseudo Color Image
At first, I introduce how to convert the pseudo image by using Python-openCV.
The method is below.
“pseudo_image” and “base_image” is array of image.
“format_of_pseudo_color” can apply below options.
★”format_of_pseudo_color” Options
cv2.COLORMAP_JET
cv2.COLORMAP_HOT
cv2.COLORMAP_HSV
cv2.COLORMAP_RAINBOW
In addition to the above, you can apply other options.
If you interested in the options, please search by your self.
But I think other than above options is rarely used.
Sample Program of Making Pseudo Color Image
So, let’s demonstrate how to use above method.
The sample program is below.
#import library
import cv2
#load base image
pic=cv2.imread('original.jpg', cv2.IMREAD_GRAYSCALE)
#making COLORMAP_JET
pseudo_color = cv2.applyColorMap(pic, cv2.COLORMAP_JET)
cv2.imwrite('pseudo_color_jet.jpg',np.array(pseudo_color))
#making COLORMAP_HOT
pseudo_color = cv2.applyColorMap(pic, cv2.COLORMAP_HOT)
cv2.imwrite('pseudo_color_hot.jpg',np.array(pseudo_color))
#making COLORMAP_HSV
pseudo_color = cv2.applyColorMap(pic, cv2.COLORMAP_HSV)
cv2.imwrite('pseudo_color_hsv.jpg',np.array(pseudo_color))
#making COLORMAP_RAINBOW
pseudo_color = cv2.applyColorMap(pic, cv2.COLORMAP_RAINBOW)
cv2.imwrite('pseudo_color_rainbow.jpg',np.array(pseudo_color))
It just use above method after loading base image and save converted image.
Result of Sample Program
The result of this program is below.
The two on the left are above program and original monochrome image.
And four on the right are pseudo color image converted from original image.
Since the above image is too small, I show all images respectively at below.
◆Original Image
◆COLORMAP_JET
◆COLORMAP_HOT
◆COLORMAP_HSV
◆COLORMAP_RAINBOW
I think JET or HOT is Good!!
That’s all. Thank you!!
コメント