how can i convert detected grayscale image object back into rgb form?
1 回表示 (過去 30 日間)
古いコメントを表示
I have to detect red chilies from plant. I got this result which shown in given figure but now i have to convert this final detected chili image back into red form, how can i do this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/808449/image.jpeg)
This is the code which i used in this work.
i=imread('IMG_20210825_153633 - Copy.jpg');
subplot(2,2,1);
imshow(i)
G=rgb2gray(i);
subplot(2,2,2);
imshow(G);
A=i(:,:,1);
subplot(2,2,3);
imshow(A);
f=imsubtract(A,G);
subplot(2,2,4);
imshow(f)
0 件のコメント
採用された回答
yanqi liu
2021 年 11 月 22 日
clc; clear all; close all;
i=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/808449/image.jpeg');
i=imcrop(i,[5 8 632 291]);
subplot(2,2,1);
imshow(i)
G=rgb2gray(i);
subplot(2,2,2);
imshow(G);
A=i(:,:,1);
subplot(2,2,3);
imshow(A);
f=imsubtract(A,G);
subplot(2,2,4);
imshow(f)
bw = im2bw(mat2gray(f));
bw = imclose(bw, strel('disk', 5));
bw = bwareaopen(bw, 5);
i2 = i .* uint8(cat(3,bw,bw,bw));
figure; imshow(i2, []);
その他の回答 (2 件)
Yongjian Feng
2021 年 11 月 21 日
編集済み: Yongjian Feng
2021 年 11 月 21 日
How about changing the red chili area of the last image to alpha = 0 (so it is completely transparent). Then overlay on top of the original image
0 件のコメント
Image Analyst
2021 年 11 月 21 日
Use the Color Thresholder app on the apps tab of the tool ribbon. Load your image then choose HSV color space, then adjust the thresholds, then export the function. Easy, but if you have trouble, let us know, but attach the original image 'IMG_20210825_153633 - Copy.jpg'
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!