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 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

jyoti guru
jyoti guru am 21 Okt. 2016
yes sir thanx alot

Weitere Antworten (1)

Thorsten
Thorsten am 20 Okt. 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.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by