Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Recent Posts

Some Random effects

  • Negative Image
Subtract 255 from the RGB image, to obtain negative image.
MATLAB CODE:
%Here the  I am subtracting 255 from R,G and B.
A=imread('person.jpg');
imshow(255-A);

Original Image
Negative Image







  • Sine Wave

    First find the mid point of the RGB image.
    Convert the points from Cartesian to polar co_ordinates
    Find the sine value for the angle 'theta'
    Again convert the points to Cartesian co_ordinates

    SAMPLE CODE:
    x2=zeros([size(A,1) size(A,2)]);
    y2=zeros([size(A,1) size(A,2)]);
    for i=1:size(A,1)
        x=i-midx;
        for j=1:size(A,2)
    %Cartesian to Polar co-ordinates
               [theta1,rho1]=cart2pol(i,j-midy);
        
          
                  
            phi=sin(theta1);
          
    %Polar to Cartesian co-ordinates
            [l,m]=pol2cart(phi,rho1);
            x2(i,j)=ceil(l)+midx;
            y2(i,j)=ceil(m)+midy;
          
        end
    end

    Sine wave


Original Image

like button Like "IMAGE PROCESSING" page

Number of occurrences in cell array

To find the number of occurrence of a string in an array:

Consider a cell array
c={'one';'two';'three';'nine';'five';'two';'six';'one'; 'two';'five';};


The number of times the string ‘one’ occurs in the array

sum(strcmp('one',c))

ans =

     2

To find the number of occurrence of all the elements in the array:


%c={'one';'two';'three';'nine';'five';'two'; 'six';'one'; 'two';'five';}; %dim=1

c='one','one','two','two','three','three','three','four','five','six','five','five'};%dim=2;

dim=2;
%Initialize the 'cell_array'
cell_array=cell([2 size(c,dim)]);
display(c);
inc=1;
for i=1:size(c,dim)
    %Compare the elements in the 'cell_array' with the elements in 'c'
   if(strcmp(cell_array(1,:),c(i))==0)
       %If the element is not present, then add it to 'cell_array'.
       cell_array(1,inc)=c(i);
       %Find the number of occurence of the element
     num=   sum(strcmp(c(i),c));
     cell_array(2,inc)=num2cell(num);
     inc=inc+1;
   else
       %Delete if the element is already present in the 'cell_array'.
       cell_array(:,inc)='';
      
      
   end
  
  
end

display(cell_array);



The result shows the elements in the first row and the number of occurrences in the second row.
like button Like "IMAGE PROCESSING" page
Previous Post Next Post Home
Related Posts Plugin for WordPress, Blogger...
Twitter Bird Gadget Google ping Hypersmash.com