qwertyuiopasdfghjklzxcvbnmqwe

rtyuiopasdfghjklzxcvbnmqwertyui
opasdfghjklzxcvbnmqwertyuiopa
sdfghjklzxcvbnmqwertyuiopasdfg
M.Bilal Junaid
hjklzxcvbnmqwertyuiopasdfghjklz
Assignment :2
xcvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnmq
wertyuiopasdfghjklzxcvbnmqwert
yuiopasdfghjklzxcvbnmqwertyuio
pasdfghjklzxcvbnmqwertyuiopas
dfghjklzxcvbnmqwertyuiopasdfgh
jklzxcvbnmqwertyuiopasdfghjklzx
cvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnmq
wertyuiopasdfghjklzxcvbnmqwert
yuiopasdfghjklzxcvbnmrtyuiopas
MS(EE)-SP014-014

Advance Digital Signal Processing

2.20 0.55 0. n=length(B_new).80 0.951 -0.N).65 0.95 1].50 0. &--------------------------------%output of Frequency Response figure(2) subplot(2.n)].2) plot(B) title('Singal B') % Showing My convolution and Matlab convolution results are same. Fsmax=20 %assiming sampling at 20Mhz %taking fft with window size 128 ffta=fft(A.45 0.587 -0.fftshift(abs(ffta))) title('Frequency Response of Singal A') .m)].zeros(1. subplot(2.309 0.Answer 1 function q1() A = [ 0.90 0.809 0.70 0.30 0. for i=1:n+m-1 y(i)=0.951 1 0.309 -0.35 0.224e-16 -0.1) plot(A) title('Singal A') subplot(2.B) %-----------------------------------------------figure(1) subplot(2. end end end %-----------------------------------------------------------%Matlab Convolution Function--------------------c=conv(A. A_new=[A_new.75 0.N).15 0.587 0.1) plot([-N/2:N/2-1]*Fsmax/N.809 -0.2.309 -2.60 0.zeros(1.309 1.449e-16]. B = [ 0.809 0.4) plot(y) title('Singal C=A*B Using Matlab Convolution Function') %-------------------------------------------------------N=128.809 -0.2.85 0.587 0.25 0.951 -1 -0.40 0.587 -0.2.N).3) plot(y) title('Singal C=A*B Using Personal Convolution Function') subplot(2.10 0. %personal Convolution Function-------------------------A_new=A B_new=B m=length(A_new).05 0. fftc=fft(y.2. fftb=fft(B. B_new=[B_new. for j=1:m if(i-j+1>0) y(i)=y(i)+A_new(j)*B_new(i-j+1).951 0.

2.fftshift(abs(fftb))) title('Frequency Response of Signal B') subplot(2.subplot(2.2.2) plot([-N/2:N/2-1]*Fsmax/N.fftshift(abs(fftc))) title('Frequency Response of Singal C') %----------------------------------end Output of Question 1 Answer 2 .[3 4]) plot([-N/2:N/2-1]*Fsmax/N.

12.12.2. xbegin = xoffset+1.xbegin:xend. %-----------------------------------------% finding top left coordinates of rectangular image pattern in image [max_c.1))].'FontSize'. ybegin = yoffset+1.2.'r') subplot(1. [ypeak.extracted_image) disp('Huraah!! Success:: Image Pattern was extracted from Image') %top Left cooridnates of image pattern X_coordinate_topleft_of_pattern = xoffset. %-----------------------------------------------------------------------% extract image pattern from image from the results of cross corelation and compare to already provided image pattern extracted_image = image(ybegin:yend. %------------------------------------------------------------------- %plotting already provided image pattern and Recovered image to check %Image match was correct or not .'r') %-------------------------------------%cross correlation between image pattern and image to find where image %pattern is most likely to exist in image c = normxcorr2(image_pattern. yoffset = corr_offset(2).1) imshow(image_pattern) title('Image Pattern'. xoffset = corr_offset(1). xend = xoffset+ size(image_pattern.2). corr_offset = [(xpeak-size(image_pattern. Y_coordinate_topleft_of_patten = yoffset.'FontSize'.1).'Color'.:). xpeak] = ind2sub(size(c). Y_coordinate_center_of_pattern = yoffset + size(image_pattern. imax] = max(abs(c(:))).2)/2.1)/2.'Color'.2)) (ypeak-size(image_pattern.%loading both images--------------load image load image_pattern %----------------------------------%plotting image Pattern and Image--------figure(1) subplot(1. %------------------------------------------%Center Coordiantes of image Pattern X_coordinate_center_of_pattern = xoffset + size(image_pattern. yend = yoffset+size(image_pattern.imax(1)). if isequal(image_pattern.2) imshow(image) title('Image'.image).

n.'FontSize'. fprintf('X_coordinate(Center) = %f\n'.'Color'. recovered_image(ybegin:yend. fprintf('Y_coordinate(Top-left) = %f\n'. i = find(recovered_image(:.X_coordinate_center_of_pattern).1)==0).1)) hold on h = imshow(recovered_image).X_coordinate_topleft_of_pattern).6.12. title('Masked Recovered image over orignal image'. %---------------------------------------------------------------- Output Of Question 2 . fprintf('Y_coordinate(Center) = %f\n'. imshow(image(:.xbegin:xend.figure.2) imshow(extracted_image) %recovered image from cross corelation title('Image pattern recovered image from cross corelation'.'AlphaData'.12.:.'r') set(h.n).'Color'. recovered_image = uint8(zeros(size(image))).:) = image_pattern.'r') %---------------------------------------------------------------end %showing extracted image pattern over Orignal Image.12.2.'FontSize'.'Color'.:.mask) %-----------------------------------------%Displaying Coordiantes---------------------------------fprintf('Coordinate are : \n\n') fprintf('X_coordinate(Top-left) = %f\n'.1) imshow(image_pattern)%image pattern provided title('Image pattern provided'. % adding Transperancy % overlay images with transparency figure.'r') subplot(1. subplot(1.2.Y_coordinate_topleft_of_patten).Y_coordinate_center_of_pattern). mask(i) = . [m. mask = ones(m.'FontSize'.p] = size(image).

.

'Color'. xend = xoffset+ size(shifter_ocr_block.imshow(shifter_ocr_block) title('Extracted Block of character from Orignal Image'.2). [ypeak.imshow(extracted_image) title('Image Recovered After Cross-Corelation'.Answer 3 load shifted_ocr %View from Imview to find exact pixels and size to extract one character %from OCR diagram.2)) ]. %showing cropped image figure.ybegin:yend.1).[48 36 15 18]).imax(1)). fprintf('Image is offset by : \n %d %d \n'. imview(shifted_ocr) %cropping character 'C' from original image shifter_ocr_block = imcrop(shifted_ocr. yoffset = corr_offset(2). %finding coordinates of co-relation [max_cc.'r') %cross corelation with extracted block and orignal image cc = normxcorr2(shifter_ocr_block. imax] = max(abs(cc(:))).x(1).'Color'.1)) (xpeak-size(shifter_ocr_block. ybegin = yoffset+1.shifted_ocr). xoffset = corr_offset(1). figure. xpeak] = ind2sub(size(cc). corr_offset = [ (ypeak-size(shifter_ocr_block.:). %-----------------------------------------------------------------------% extract image pattern from image from the results of cross corelation and compare to already provided image pattern extracted_image = shifted_ocr(xbegin:xend.x(2)) Output Of Question 3 . yend = yoffset+size(shifter_ocr_block. xbegin = xoffset+1.'r') %find scaled offset of extracted character x=[36 48]-corr_offset.

.

figure.2). shifted_ocr_new=AWGN(shifted_ocr. ybegin = yoffset+1.'r') %cross corelation with extracted block and orignal image cc = normxcorr2(shifter_ocr_block.imax(1)). xoffset = corr_offset(1).shifted_ocr_new).imshow(shifted_ocr_new) %cropping character 'C' from original image shifter_ocr_block = imcrop(shifted_ocr. xpeak] = ind2sub(size(cc).ybegin:yend). xend = xoffset+ size(shifter_ocr_block. imax] = max(abs(cc(:))). %showing cropped image figure.x(2)) %REsults with SNR=-10DB %View from Imview to find exact pixels and size to extract one character %from OCR diagram. %finding coordinates of co-relation [max_cc. fprintf('Image is offset with SNR=-20: \n %d %d \n'. %-----------------------------------------------------------------------% extract image pattern from image from the results of cross corelation and compare to already provided image pattern extracted_image = shifted_ocr_new(xbegin:xend.2)) ].imax(1)). .imshow(shifter_ocr_block) title('Extracted Block of character from Orignal Image'.x(1).'r') %find scaled offset of extracted character x=[36 48]-corr_offset. yoffset = corr_offset(2).1).-20.2)) ]. figure.[48 36 15 18]).-10.shifted_ocr_new).1)) (xpeak-size(shifter_ocr_block.1)) (xpeak-size(shifter_ocr_block. [ypeak.imshow(shifted_ocr_new) %cropping character 'C' from original image shifter_ocr_block = imcrop(shifted_ocr. %showing cropped image figure.Answer 4 load shifted_ocr %REsults with SNR=-20DB %View from Imview to find exact pixels and size to extract one character %from OCR diagram.'r') %cross corelation with extracted block and orignal image cc = normxcorr2(shifter_ocr_block. imshow(shifted_ocr) shifted_ocr=im2double(shifted_ocr). xpeak] = ind2sub(size(cc).[48 36 15 18]). shifted_ocr_new=AWGN(shifted_ocr.'Color'. xbegin = xoffset+1.'Color'. %finding coordinates of co-relation [max_cc. imax] = max(abs(cc(:))). yend = yoffset+size(shifter_ocr_block. corr_offset = [ (ypeak-size(shifter_ocr_block. [ypeak.'measured').imshow(extracted_image) title('Image Recovered After Cross-Corelation'.imshow(shifter_ocr_block) title('Extracted Block of character from Orignal Image'. figure. imshow(shifted_ocr) shifted_ocr=im2double(shifted_ocr).'Color'.'measured'). corr_offset = [ (ypeak-size(shifter_ocr_block.

shifted_ocr_new). xbegin = xoffset+1.'Color'. xbegin = xoffset+1.'r') %cross corelation with extracted block and orignal image cc = normxcorr2(shifter_ocr_block.10.'Color'.'r') %find scaled offset of extracted character x=[36 48]-corr_offset.ybegin:yend).1)) (xpeak-size(shifter_ocr_block.2)) ].'Color'. shifted_ocr_new=AWGN(shifted_ocr.imshow(shifted_ocr_new) . figure. %-----------------------------------------------------------------------% extract image pattern from image from the results of cross corelation and compare to already provided image pattern extracted_image = shifted_ocr_new(xbegin:xend. yend = yoffset+size(shifter_ocr_block.x(2)) %REsults with SNR=0DB %View from Imview to find exact pixels and size to extract one character %from OCR diagram.[48 36 15 18]).imshow(extracted_image) title('Image Recovered After Cross-Corelation'.1). xend = xoffset+ size(shifter_ocr_block. imshow(shifted_ocr) shifted_ocr=im2double(shifted_ocr). yoffset = corr_offset(2).imshow(extracted_image) title('Image Recovered After Cross-Corelation'. %finding coordinates of co-relation [max_cc. xoffset = corr_offset(1). ybegin = yoffset+1. shifted_ocr_new=AWGN(shifted_ocr. imax] = max(abs(cc(:))).x(1).x(1). yoffset = corr_offset(2). figure.2). xpeak] = ind2sub(size(cc).'measured'). corr_offset = [ (ypeak-size(shifter_ocr_block.1).imax(1)). ybegin = yoffset+1. %-----------------------------------------------------------------------% extract image pattern from image from the results of cross corelation and compare to already provided image pattern extracted_image = shifted_ocr_new(xbegin:xend. figure.'r') %find scaled offset of extracted character x=[36 48]-corr_offset.2).'measured'). fprintf('Image is offset with SNR=-10: \n %d %d \n'. %showing cropped image figure.x(2)) %REsults with SNR=10DB %View from Imview to find exact pixels and size to extract one character %from OCR diagram. [ypeak. yend = yoffset+size(shifter_ocr_block. imshow(shifted_ocr) shifted_ocr=im2double(shifted_ocr). figure.xoffset = corr_offset(1). fprintf('Image is offset with SNR=0: \n %d %d \n'.ybegin:yend).0.imshow(shifter_ocr_block) title('Extracted Block of character from Orignal Image'. xend = xoffset+ size(shifter_ocr_block.imshow(shifted_ocr_new) %cropping character 'C' from original image shifter_ocr_block = imcrop(shifted_ocr.

xpeak] = ind2sub(size(cc). yend = yoffset+size(shifter_ocr_block.2)) ].x(1). ybegin = yoffset+1.imshow(shifter_ocr_block) title('Extracted Block of character from Orignal Image'. [ypeak. xbegin = xoffset+1.imshow(extracted_image) title('Image Recovered After Cross-Corelation'. fprintf('Image is offset with SNR=10: \n %d %d \n'. figure. %finding coordinates of co-relation [max_cc. xend = xoffset+ size(shifter_ocr_block.'Color'. corr_offset = [ (ypeak-size(shifter_ocr_block.'Color'.'r') %cross corelation with extracted block and orignal image cc = normxcorr2(shifter_ocr_block.x(2)) Output Question 4 . yoffset = corr_offset(2).1)) (xpeak-size(shifter_ocr_block.ybegin:yend).shifted_ocr_new).[48 36 15 18]).2). %-----------------------------------------------------------------------% extract image pattern from image from the results of cross corelation and compare to already provided image pattern extracted_image = shifted_ocr_new(xbegin:xend. xoffset = corr_offset(1). %showing cropped image figure.imax(1)).'r') %find scaled offset of extracted character x=[36 48]-corr_offset.%cropping character 'C' from original image shifter_ocr_block = imcrop(shifted_ocr. imax] = max(abs(cc(:))).1).

.

.

As the value of SNR degrades its become more and more difficult for co-relation to find exact match of block over entire image hence accuracy of shifting factor also decreased. .