i have to save colour thresholded images in different folder according to their rgb values , but i can't work ..all the images are showing with the imshow() function but it can't stored on different folder as per their rgb values..pls help this out
1 次查看(过去 30 天)
显示 更早的评论
srcFiles=dir('C:\Users\om\Desktop\research\*.jpg');
for i=1: length(srcFiles);
filename=strcat('C:\Users\om\Desktop\research\',srcFiles(i).name);
figure;
i=imread(filename);
imshow(filename);
red=i(:,:,1); green=i(:,:,2); blue=i(:,:,3);
imshow(red);
imshow(green);
imshow(blue);
if(out == red>88 & red<111 & green >86 & green <104 & blue> 73 & blue<97);
imwrite(i,'C:\Users\om\Desktop\images\filename.jpg','jpg');
end
end
this is the code i applied
采纳的回答
更多回答(1 个)
Thorsten
2016-10-20
Something is wrong with your condition, "out" is undefined.
You can write
if(red>88 & red<111 & green >86 & green <104 & blue> 73 & blue<97);
imwrite(i,'C:\Users\om\Desktop\images\filename.jpg','jpg');
end
But the condition will be true if all pixels in the image fullfil the conditions, i.e., all pixels in the red channel are between 88 and 111, and all pixels in the green channels are between 86 and 104, and all in the blue channel between 73 and 97. If that is what you want, this code works.
If you want something else, please let us know.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!