Saturday, June 8, 2013

new code


for i1=5:1:15
for j1=5:1:20
sum1=0;
sum1=int8(img1gray(i1,j1))

for k1=1:1:4
printf("\n%d",int8(img1gray(i1,j1-k1)));
printf("\n%d",img1gray(i1,j1+k1));
printf("\n%d",img1gray(i1-k1,j1));
printf("\n%d\n",img1gray(i1+k1,j1));sum1
a=int8(img1gray(i1,j1-k1));
b=int8(img1gray(i1,j1+k1));
c=int8(img1gray(i1-k1,j1));
d=int8(img1gray(i1+k1,j1));
#sum1=sum1+int8(img1gray(i1,j1-k1))+int8(img1gray(i1,j1+k1))+int8(img1gray(i1-k1,j1))+int8(img1gray(i1+k1,j1))
sum1=sum1+a+b+c+d
endfor
printf("\nSum for img1gray(%d,%d):%d",i1,j1,sum1)
avg1=0;
avg1=sum1/17;
printf("\nAverage for img1gray(%d,%d)=%d",i1,j1,avg1)
for i2=5:1:15
for j2=5:1:20
sum2=0;
sum2=img2gray(i2,j2);
for k2=1:1:4
sum2=sum2+img2gray(i2,j2-k2)+img2gray(i2,j2+k2)+img2gray(i2-k2,j2)+img2gray(i2+k2,j2);
endfor
printf("\nSum for img2gray(%d,%d):%d",i2,j2,sum2)
avg2=0;
avg2=sum2/17;
printf("\nAverage for img1gray(%d,%d)=%d",i2,j2,avg2)
#sub=avg2-avg1;
#printf("\nSubtarcting result for average of img2gray(%d,%d) and average of img1gray(%d,%d):sub",i2,j2,i1,j1,sub)
#if sub <15 & sub > 0 || sub > -15 & sub < 0
#printf("\nimg1gray(%d,%d) is in comparision to img2gray(%d,%d)",i1,j1,i2,j2);
#else
#printf("\nnot matched\n");
#endif
endfor
endfor
endfor
endfor

Friday, June 7, 2013

gray average



 for i=2:1:1535;for j=2:1:2046;imggray(i,j)=(imggray(i,j-1)+imggray(i,j+1)+imggray(i+1,j)+imggray(i-1,j))/4;endfor;endfor;

Monday, June 3, 2013

multithreading example using openmp


#include<stdio.h>
#include<omp.h>

int main()
{
int i=0;
omp_set_num_threads(16);
#pragma omp parallel
{
for (i=0;i<9999999999;i++);
printf("%d",i);
}
return 0;
}

image tilting

original image


for i=1:2:1000;img(i,:,:)=img(i+1,:,:);endfor
imshow(img)

for i=1:2:500;img(i,:,:)=0;endfor
imshow(img)
for i=1:2:1000;img(i,:,:)=img(i+1,:,:);endfor
imshow(img)

upper 50 rows are tilted
for i=1:1:50;img(i,:,:)=img(i*8,:,:);endfor
imshow(img)
now tilting other 200
for i=50:1:200;img(i,:,:)=img(i*6,:,:);endfor
imshow(img)

for i=200:1:250;img(i,:,:)=img(i*4,:,:);endfor
imshow(img)


oops thats a mistake


===>>>>now doing it again
for i=1:1:50;img(i,:,:)=img(i*8,:,:);endfor

for i=50:1:200;img(i,:,:)=img(i*6+100,:,:);endfor
for i=50:1:200;img(i,:,:)=img(i*6+100,:,:);endfor
imshow(img)


expansion of the above 250 rows of above image as full image
for i=250:-1:1;img(i*6,:,:)=img(i,:,:);img(i*6-1,:,:)=img(i,:,:);img(i*6-2,:,:)=img(i,:,:);;img(i*6-3,:,:)=img(i,:,:);img(i*6-4,:,:);img(i*6-5,:,:);endfor
imshow(img)




Friday, May 31, 2013

blurred image fifa


-1->for r=2:1:1078
-1->for c=2:1:1918
-1->for k=1:1:3
-1->img(r,c,k)=(img(r-1,c,k)+img(r+1,c,k)+img(r,c-1,k)+img(r,c+1,k)+img(r,c,k))/5;
-1->end
-1->end
-1->end




Friday, May 17, 2013

error in scilab

error:
The shared archive was not loaded: libjpeg.so.62: cannot open shared object file: No such file or dir

solution:
http://ubuntuforums.org/showthread.php?t=1846079
sudo apt-get install libjpeg62

Tuesday, May 14, 2013

code


img=imread('8.jpg');
figure(1);imshow(img);
print -dpng a.png;
img_gray=rgb2gray(img);
figure(2);imshow(img_gray);
print -dpng b.png;
img_red=img;
img_red(:,:,2)=0;
img_red(:,:,3)=0;
figure(3);imshow(img_red);
print -dpng c.png;
img_green=img;
img_green(:,:,1)=0;
img_green(:,:,3)=0;
figure(4);imshow(img_green);
print -dpng d.png;
img_blue=img;
img_blue(:,:,1)=0;
img_blue(:,:,2)=0;
figure(5);imshow(img_blue);
print -dpng e.png;
img_gray_fft=fft2(img_gray);
img_red_fft=fft2(img_red);
img_green_fft=fft2(img_green);
img_blue_fft=fft2(img_blue);
figure(6);imshow(img_gray_fft);
print -dpng f.png;
figure(7);imshow(abs(img_gray_fft));
print -dpng g.png;
figure(8);imshow(imadjust(img_gray_fft));
print -dpng h.png;
figure(9);imshow(imadjust(abs(img_gray_fft)));
print -dpng i.png;
figure(10);imshow(fftshift(img_gray_fft));
print -dpng j.png;
figure(11);imshow(fftshift(abs(img_gray_fft)));
print -dpng k.png;
figure(12);imshow(fftshift(imadjust(img_gray_fft)));
print -dpng l.png;
figure(13);imshow(fftshift(imadjust(abs(img_gray_fft))));
print -dpng m.png;
figure(14);imshow(img_red_fft);
print -dpng n.png;
figure(15);imshow(abs(img_red_fft));
print -dpng o.png;
figure(16);imshow(imadjust(img_red_fft));
print -dpng p.png;
figure(17);imshow(imadjust(abs(img_red_fft)));
print -dpng q.png;
figure(18);imshow(fftshift(img_red_fft));
print -dpng r.png;
figure(19);imshow(fftshift(abs(img_red_fft)));
print -dpng s.png;
figure(20);imshow(fftshift(imadjust(img_red_fft)));
print -dpng t.png;
figure(21);imshow(fftshift(imadjust(abs(img_red_fft))));
print -dpng u.png;
figure(22);imshow(img_green_fft);
print -dpng v.png;
figure(23);imshow(abs(img_green_fft));
print -dpng w.png;
figure(24);imshow(imadjust(img_green_fft));
print -dpng x.png;
figure(25);imshow(imadjust(abs(img_green_fft)));
print -dpng y.png;
figure(26);imshow(fftshift(img_green_fft));
print -dpng z.png;
figure(27);imshow(fftshift(abs(img_green_fft)));
print -dpng z1.png;
figure(28);imshow(fftshift(imadjust(img_green_fft)));
print -dpng z2.png;
figure(29);imshow(fftshift(imadjust(abs(img_green_fft))));
print -dpng z3.png;
figure(30);imshow(img_blue_fft);
print -dpng z4.png;
figure(31);imshow(abs(img_blue_fft));
print -dpng z5.png;
figure(32);imshow(imadjust(img_blue_fft));
print -dpng z6.png;
figure(33);imshow(imadjust(abs(img_blue_fft)));
print -dpng z7.png;
figure(34);imshow(fftshift(img_blue_fft));
print -dpng z8.png;
figure(35);imshow(fftshift(abs(img_blue_fft)));
print -dpng z9.png;
figure(36);imshow(fftshift(imadjust(img_blue_fft)));
print -dpng z91.png;
figure(37);imshow(fftshift(imadjust(abs(img_blue_fft))));
print -dpng z92.png;