Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

i have divide n images into 4 equal parts present in the database now i want calculate the color values from each part of the images using the following code.plz ans me

1 visualizzazione (ultimi 30 giorni)
srcFiles=dir('fruits\*.jpg'); for i= 1:length(srcFiles) Filename=strcat('fruits\',srcFiles(i).name); I=imread(Filename); imshow(I) [x,y, z]=size(I) I_1=imcrop(I,[1 1 y/2 x/2]) figure,imshow(I_1); I_2=imcrop(I,[y/2 1 y/2 x/2]) figure,imshow(I_2); I_3=imcrop(I,[1 x/2 y/2 x/2]) figure,imshow(I_3); I_4=imcrop(I,[y/2 x/2 y/2 x/2]) figure,imshow(I_4);
for j=1:4 imread(I_i) [index, map]=rgb2ind(I_i,65300); pixels= prod(size(index)); hsv=rgb2hsv(map); h = hsv(:,1); s = hsv(:,2); v = hsv(:,3); darks = find(v <.2)'; lights = find(s < .05 & v > .85)'; h([darks lights])= -1; disp(length(darks)) black = length(darks)/pixels;[x,y, z]=size(I); white = length(lights)/pixels; red = length(find((h >.9167 | h <=.083) & h~=-1))/pixels; yellow=length(find(h >.083 & h<=.25))/pixels; green=length(find(h > .25 & h<= .4167))/pixels; cyan= length(find(h > .4167 & h<= .5833))/pixels; blue=length(find(h > .5833 & h <= .75))/pixels; magenta=length(find(h > .75 & h <= .9167))/pixels; disp('Red=') disp(red) disp('Blue=') disp(blue) a(j,1)=red a(j,2)=green a(j,3)=blue a(j,4)=yellow a(j,5)=cyan a(j,6)=magenta a(j,7)=black a(j,8)=white end dlmwrite('frs_j.mat',a) b=dlmread('frs_j.mat') end
fill([0 0 1 1], [0 red red 0], 'r') fill([1 1 2 2],[0 yellow yellow 0], 'y') fill([2 2 3 3],[0 green green 0], 'g') fill([3 3 4 4],[0 cyan cyan 0], 'c') fill([4 4 5 5],[0 blue blue 0], 'b') fill([5 5 6 6],[0 magenta magenta 0], 'm') fill([6 6 7 7],[0 white white 0], 'w') fill([7 7 8 8],[0 black black 0], 'k') axis([0 8 0 1])

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by