summaryrefslogtreecommitdiff
path: root/125/DEPENDENCIES
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /125/DEPENDENCIES
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '125/DEPENDENCIES')
-rwxr-xr-x125/DEPENDENCIES/Func_medianall.sci36
-rwxr-xr-x125/DEPENDENCIES/conv2d2.sce23
-rwxr-xr-x125/DEPENDENCIES/dct_mtx.sce7
-rwxr-xr-x125/DEPENDENCIES/dft_mtx.sce18
-rwxr-xr-x125/DEPENDENCIES/fft2d.sce25
-rwxr-xr-x125/DEPENDENCIES/gray.sci4
-rwxr-xr-x125/DEPENDENCIES/grayslice.sci51
-rwxr-xr-x125/DEPENDENCIES/ifft2d.sce17
-rwxr-xr-x125/DEPENDENCIES/rgb2ycbcr_1.sci11
9 files changed, 192 insertions, 0 deletions
diff --git a/125/DEPENDENCIES/Func_medianall.sci b/125/DEPENDENCIES/Func_medianall.sci
new file mode 100755
index 000000000..ecf3273ba
--- /dev/null
+++ b/125/DEPENDENCIES/Func_medianall.sci
@@ -0,0 +1,36 @@
+//The input to the function are the corrupted image ‘a’ and the dimension
+function [Out_Imag] = Func_medianall(a,N)
+a=double(a);
+[m n]=size(a);
+Out_Imag=a;
+if(modulo(N,2)==1)
+Start=(N+1)/2;
+End=Start;
+else
+ Start=N/2;
+ End=Start+1;
+end
+if(modulo(N,2)==1)
+ limit1=(N-1)/2;
+ limit2=limit1;
+else
+ limit1=(N/2)-1;
+ limit2=limit1+1;
+end
+for i=Start:(m-End+1),
+ for j=Start:(n-End+1),
+ I=1;
+ for k=-limit1:limit2,
+ for l=-limit1:limit2,
+ mat(I)=a(i+k,j+l);
+ I=I+1;
+ end
+ end
+ mat=gsort(mat); //Sort the elements to find the median
+ if(modulo(N,2)==1)
+ Out_Imag(i,j)=(mat(((N^2)+1)/2));
+ else
+ Out_Imag(i,j)=(mat((N^2)/2)+mat(((N^2)/2)+1))/2;
+ end
+ end
+end \ No newline at end of file
diff --git a/125/DEPENDENCIES/conv2d2.sce b/125/DEPENDENCIES/conv2d2.sce
new file mode 100755
index 000000000..37350beba
--- /dev/null
+++ b/125/DEPENDENCIES/conv2d2.sce
@@ -0,0 +1,23 @@
+function [y,X,H] = conv2d2(x,h)
+
+[x1,x2] = size(x);
+[h1,h2] = size(h);
+X = zeros(x1+h1-1,x2+h2-1);
+H = zeros(x1+h1-1,x2+h2-1);
+Y = zeros(x1+h1-1,x2+h2-1);
+for i = 1:x1
+ for j = 1:x2
+ X(i,j)=x(i,j);
+ end
+end
+for i =1:h1
+ for j = 1:h2
+ H(i,j)=h(i,j);
+ end
+end
+disp(X,'x=')
+disp(H,'h =')
+Y = fft2d(X).*fft2d(H);
+disp(Y)
+y = ifft2d(Y);
+endfunction \ No newline at end of file
diff --git a/125/DEPENDENCIES/dct_mtx.sce b/125/DEPENDENCIES/dct_mtx.sce
new file mode 100755
index 000000000..b42bec4a8
--- /dev/null
+++ b/125/DEPENDENCIES/dct_mtx.sce
@@ -0,0 +1,7 @@
+function[DCT] = dct_mtx(n)
+[cc,rr] = meshgrid(0:n-1);
+//disp(cc)
+//disp(rr)
+DCT = sqrt(2 / n) * cos(%pi * (2*cc + 1) .* rr / (2 * n));
+DCT(1,:) = DCT(1,:) / sqrt(2);
+endfunction \ No newline at end of file
diff --git a/125/DEPENDENCIES/dft_mtx.sce b/125/DEPENDENCIES/dft_mtx.sce
new file mode 100755
index 000000000..aaee76368
--- /dev/null
+++ b/125/DEPENDENCIES/dft_mtx.sce
@@ -0,0 +1,18 @@
+function [D] = dft_mtx(n)
+f = 2*%pi/n; // Angular increment.
+w = (0:f:2*%pi-f/2).' *%i; //Column.
+//disp(w)
+x = 0:n-1; // Row.
+D = exp(-w*x); // Exponent of outer product.
+for i = 1:n
+ for j = 1:n
+ if((abs(real(D(i,j)))<0.0001)&(abs(imag(D(i,j)))<0.0001))
+ D(i,j)=0;
+ elseif(abs(real(D(i,j)))<0.0001)
+ D(i,j)= 0+%i*imag(D(i,j));
+ elseif(abs(imag(D(i,j)))<0.0001)
+ D(i,j)= real(D(i,j))+0;
+ end
+ end
+end
+endfunction \ No newline at end of file
diff --git a/125/DEPENDENCIES/fft2d.sce b/125/DEPENDENCIES/fft2d.sce
new file mode 100755
index 000000000..7cb43b663
--- /dev/null
+++ b/125/DEPENDENCIES/fft2d.sce
@@ -0,0 +1,25 @@
+function [a2] = fft2d(a)
+//a = any real or complex 2D matrix
+//a2 = 2D-DFT of 2D matrix 'a'
+m=size(a,1)
+n=size(a,2)
+// fourier transform along the rows
+for i=1:n
+a1(:,i)=exp(-2*%i*%pi*(0:m-1)'.*.(0:m-1)/m)*a(:,i)
+end
+// fourier transform along the columns
+for j=1:m
+a2temp=exp(-2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*(a1(j,:)).'
+a2(j,:)=a2temp.'
+end
+for i = 1:m
+ for j = 1:n
+ if((abs(real(a2(i,j)))<0.0001)&(abs(imag(a2(i,j)))<0.0001))
+ a2(i,j)=0;
+ elseif(abs(real(a2(i,j)))<0.0001)
+ a2(i,j)= 0+%i*imag(a2(i,j));
+ elseif(abs(imag(a2(i,j)))<0.0001)
+ a2(i,j)= real(a2(i,j))+0;
+ end
+ end
+end \ No newline at end of file
diff --git a/125/DEPENDENCIES/gray.sci b/125/DEPENDENCIES/gray.sci
new file mode 100755
index 000000000..6630e04e8
--- /dev/null
+++ b/125/DEPENDENCIES/gray.sci
@@ -0,0 +1,4 @@
+function [g] = gray(m)
+ g = (0:m-1)'/max(m-1,1)
+g = [g g g]
+endfunction \ No newline at end of file
diff --git a/125/DEPENDENCIES/grayslice.sci b/125/DEPENDENCIES/grayslice.sci
new file mode 100755
index 000000000..ac6012f54
--- /dev/null
+++ b/125/DEPENDENCIES/grayslice.sci
@@ -0,0 +1,51 @@
+function [bout] = grayslice(I,z)
+
+// Output variables initialisation (not found in input variables)
+bout=[];
+
+// Number of arguments in function call
+[%nargout,%nargin] = argn(0)
+
+if %nargin==1 then
+ z = 10;
+elseif ~type(z)==1 then
+ z = double(z);
+end;
+n = z;
+if typeof(I)=="uint8" then
+ z = (255*(0:n-1))/n;
+elseif isa(I, 'uint16') | isa(I, 'int16') then
+ z = 65535*(0:(n-1))/n;
+else // I is double or single
+ z = (0:(n-1))/n
+end;
+[m,n] = size(I);
+b = zeros(m,n);
+// Loop over all intervals, except the last
+for i = 1:length(z)-1
+ // j is the index value we will output, so it depend upon storage class
+ if typeof(b)=='uint8'
+ j = i-1;
+ else
+ j = i;
+ end
+ d = find(I>=z(i) & I<z(i+1));
+ if ~isempty(d),
+ b(d) = j;
+ end
+end
+
+// Take care of that last interval
+d = find(I >= z($));
+if ~isempty(d) then
+ // j is the index value we will output, so it depend upon storage class
+ if typeof(b)=="uint8" then
+ j = length(z)-1;
+ else
+ j = length(z);
+ end;
+ b(d) = j;
+end;
+bout = b;
+bout = double(bout);
+endfunction \ No newline at end of file
diff --git a/125/DEPENDENCIES/ifft2d.sce b/125/DEPENDENCIES/ifft2d.sce
new file mode 100755
index 000000000..cae21fae0
--- /dev/null
+++ b/125/DEPENDENCIES/ifft2d.sce
@@ -0,0 +1,17 @@
+function [a] =ifft2d(a2)
+//a2 = 2D-DFT of any real or complex 2D matrix
+//a = 2D-IDFT of a2
+m=size(a2,1)
+n=size(a2,2)
+//Inverse Fourier transform along the rows
+for i=1:n
+a1(:,i)=exp(2*%i*%pi*(0:m-1)'.*.(0:m-1)/m)*a2(:,i)
+end
+//Inverse fourier transform along the columns
+for j=1:m
+atemp=exp(2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*(a1(j,:)).'
+a(j,:)=atemp.'
+end
+a = a/(m*n)
+a = real(a)
+endfunction \ No newline at end of file
diff --git a/125/DEPENDENCIES/rgb2ycbcr_1.sci b/125/DEPENDENCIES/rgb2ycbcr_1.sci
new file mode 100755
index 000000000..19f37604d
--- /dev/null
+++ b/125/DEPENDENCIES/rgb2ycbcr_1.sci
@@ -0,0 +1,11 @@
+function [ycc] = rgb2ycbcr_1(rgb)
+ //rgb=im2double(rgb);
+ rgb = double(rgb)
+ tmp=int_cvtcolor(rgb, 'rgb2ycrcb');
+ ycc=zeros(tmp);
+
+ ycc(:,:,1) = tmp(:,:,1);
+ ycc(:,:,2) = tmp(:,:,3);
+ ycc(:,:,3) = tmp(:,:,2);
+ clear tmp;
+endfunction \ No newline at end of file