IMAGE PROCESSING

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

Optical Illusion – Circle

Let us define a circle and assign different color to each one of the four quadrants.

MATLAB CODE:

color_cir= uint8([size(nh,1) size(nh,2) 3]);
nh =uint8(nh);

%Color Blue

%color pink

%color Green

%Color Red

imshow(color_cir);

Concentric Circles:
Colored:
MATLAB CODE:
clc
clear all

color_cir =  uint8([size(nh,1) size(nh,2) 3]);
nh  = uint8(nh);

color_cir(1:size(nh,1),1:size(nh,2),1) = nh*10;
color_cir(1:size(nh,1),1:size(nh,2),2) = nh*1;
color_cir(1:size(nh,1),1:size(nh,2),3) = nh*2;

nh  = uint8(nh);

%Color Red

%Color Green

%Color Blue

%Color yellow

end

figure,imshow(color_cir);

EXPLANATION:
1.      Draw a circle of radius 600.
2.      Fill the circle with black color.
3.      Draw another circle of radius 550 and fill the first quadrant will green, second quadrant with red, third quadrant with blue and the fourth quadrant with yellow color.
4.      Place the smaller circle (radius 550) on the bigger circle (radius 600).
5.      Draw another circle of radius 500 and repeat the same process till the radius of the smaller circle is 50.

Black and White:
MATLAB CODE:
clc
clear all

color_cir =  double([size(nh,1) size(nh,2) 3]);
nh  = double(nh);

color_cir(1:size(nh,1),1:size(nh,2),1) = nh*1;
color_cir(1:size(nh,1),1:size(nh,2),2) = nh*1;
color_cir(1:size(nh,1),1:size(nh,2),3) = nh*1;

c1 = 0;
c2 = 255;

nh  = double(nh);

if(c2 > 1)
c1 = 255;
c2 = -255;
else
c1 = -255;
c2 = 255;
end

end

color_cir = uint8(color_cir);
figure,imshow(color_cir);

EXPLANATION:
1.      Draw a circle of radius 1250.
2.      Fill it with black color.
3.      Draw another circle with radius 1200.
4.      Fill second and fourth quadrant of the smaller circle with white color.
5.      Fill First and Third quadrant of the smaller circle with black color.
6.      Place the smaller circle on the bigger circle.
7.      Define another circle of radius 1150.
8.      Fill second and fourth quadrant of the smaller circle with black color.
9.      Fill First and Third quadrant of the smaller circle with white color.
10.  Now place this circle on the bigger one. Repeat this process with smaller circles and by interchanging black and white color on the quadrants for each circle.

Concentric circle - 2:

MATLAB CODE:

%Define the matrix
[x,y] = meshgrid(-600:600);

%Preallocate
ccircle = zeros(size(x));
for i = 500:-10:1

Tmp = x.^2 + y.^2 <= i*i;

%Find the gradient of the image

ccircle = ccircle + Gmag;
end

figure,imshow(ccircle);

Like "IMAGE PROCESSING" page