Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

Color Palette matlab code


This is my first attempt on designing a color palette. Of course, this looks quite simple.
The palette contains primary colors R,G and B.
%size of the square
sz=50;
%Number of rows
xvalue=10;
%Number of Columns
yvalue=10;
%Initialize the matrix with zeros
RGB=zeros([sz+2 sz+2 3]);
%The image shade from darker to lighter.Instead of 255 give values lesser than 255 and see the different shades
v=round(255/yvalue);

clear C
 m=sz+2;
 n=1;
    %The same color repetition. If you specify val=1 then the colors  R,G,B
    %will occur repeatedly
    val=floor(xvalue/3);
   
    inc=1;
for i=1:xvalue
    n1=1;
    m1=sz+2;
    if(inc==1)
        %Red color will be displayed
    num1=20;
    num2=1;
    num3=1;
    elseif(inc==2)
        %Green color will be displayed
    num1=1;
    num2=20;
    num3=1;
    elseif(inc==3)
        %Blue color will be displayed
    num1=1;
    num2=1;
    num3=25;
   
    end
    for j=1:yvalue
        RGB(2:sz+1,2:sz+1,1)=num1*v*j;
        RGB(2:sz+1,2:sz+1,2)=num2*v*j;
        RGB(2:sz+1,2:sz+1,3)=num3*v*j;
       
              
        C(n:m,n1:m1,:)=RGB;
             
        m1=m1+sz;
        n1=n1+sz;
            
      
    end
    n=n+sz;
    m=m+sz;
    if(mod(i,val)==0)
       
        inc=inc+1;
    
        if(inc>3)
            inc=1;
        end
    end
   
   
end

C=uint8(C);
imshow(C);

10X10

5X10
             

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.