Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

calculation of graycoprops function and sorting of values of graycoprops

Asked by pammy

pammy (view profile)

on 6 Mar 2013
          I=imread('liftingbody.png'); 
          G=graycomatrix(I);
          [m n]=size(G);
          for x=1:m
             for y=1:n
                 stats=graycoprops(G,'contrast');
              end
          end
          Sort=sort(stats);
          fprintf('\n sorted contrast values are:\n %d',stats);

this gives error....says that stats is of struct type... i want to sort the contrast values... tel me plz how it can be done..

help me to solve my query plz

0 Comments

pammy

pammy (view profile)

1 Answer

Answer by Image Analyst

Image Analyst (view profile)

on 6 Mar 2013
Accepted answer

Type "stats" on the command line and see what it is. Then change the last few lines to this:

stats
sortedStats=sort([stats.Contrast])
fprintf('\n sorted contrast values are:\n %d\n', sortedStats);

Note the brackets around stats.Contrast to turn it into an array. But why are you looping over m and n and just overwriting the same stats scalar over and over again? It needs to be indexed so you keep the separate values.

1 Comment

pammy

pammy (view profile)

on 7 Mar 2013

thank you very much sir.

Image Analyst

Image Analyst (view profile)

Contact us