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 visualización (últimos 30 días)
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

Respuesta aceptada

jyoti guru
jyoti guru el 21 de Oct. de 2016
yes sir thanx alot

Más respuestas (1)

Thorsten
Thorsten el 20 de Oct. de 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.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by