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 view (last 30 days)
Show older comments
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
Accepted Answer
More Answers (1)
Thorsten
on 20 Oct 2016
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 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!