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 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Thorsten
il 20 Ott 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 Commenti
Vedere anche
Categorie
Scopri di più su Image Processing Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!