フィルターのクリア

How to save images!?

1 回表示 (過去 30 日間)
Rayan Matlob
Rayan Matlob 2022 年 7 月 5 日
コメント済み: DGM 2022 年 7 月 6 日
Hello, for the next code, when i run the code i get a subplot as bellow,
But when i save them, they turn into black and white.
Good_RGB=cv2.imread("R_9_1_GSM_5/Good/Original_images/"image_name)
fig, RGB = plt.subplots(1, 3, figsize=(10,10))
for j in range(3):
RGB[j].imshow(Good_RGB[:,:,j])
RGB[j].set_title(rgb_list[j], fontsize = 15)
cv2.imwrite('R_9_1_GSM_5/Good/Red/'+image_name, (Good_RGB[:,:,0]*2))
cv2.imwrite('R_9_1_GSM_5/Good/Green/'+image_name,(Good_RGB[:,:,1]*2))
cv2.imwrite('R_9_1_GSM_5/Good/Blue/'+image_name,(Good_RGB[:,:,2]*2))

回答 (1 件)

DGM
DGM 2022 年 7 月 5 日
編集済み: DGM 2022 年 7 月 6 日
I have no idea what this code is, but the images are grayscale. When you isolate one color channel, that's all it is. It's a single-channel intensity image. There is no color information.
The images shown are represented as pseudocolor images -- they have a colormap applied to them. In this case, it's probably something similar to parula() or winter(). Use ind2rgb() to apply the selected colormap to the image and create an actual color image.
inpict = imread('peppers.png');
[R G B] = imsplit(inpict);
montage({R G B}) % they're all grayscale
cmap = parula(256);
R = ind2rgb(R,cmap);
G = ind2rgb(G,cmap);
B = ind2rgb(B,cmap);
montage({R G B}) % they're all colormapped using parula()
  2 件のコメント
Rayan Matlob
Rayan Matlob 2022 年 7 月 6 日
編集済み: Rayan Matlob 2022 年 7 月 6 日
%I rewrite the code in a simple way, i need to save the previeus subplot as shown in the question. thanks
Good_RGB=cv2.imread("R_9_1_GSM_5/Good/Original_images/"image_name)
fig, RGB = plt.subplots(1, 3, figsize=(10,10))
for j in range(3):
RGB[j].imshow(Good_RGB[:,:,j])
cv2.imwrite('R_9_1_GSM_5/Good/Red/'+image_name, (Good_RGB[:,:,0]*2))
cv2.imwrite('R_9_1_GSM_5/Good/Green/'+image_name,(Good_RGB[:,:,1]*2))
cv2.imwrite('R_9_1_GSM_5/Good/Blue/'+image_name,(Good_RGB[:,:,2]*2))
DGM
DGM 2022 年 7 月 6 日
Like I said, I don't know what language that's written in. All I can do is say how it's done in MATLAB.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by