while executing my code there is no error but i did not get any output
Show older comments
while performing cross correlation i get white screen as my output.can anyone please tell me whats my mistake in my code,because i m a new matlab user.I am attaching my code for your kind reference..your help is really appreciated
clc;
clear all;
close all;
a=(im2double(imread('bookshelf.jpg')));
a=imresize(a,[255 255]);
figure();
subplot(2,2,1);
imshow(a);
b=rgb2gray(a);
% r =a(:,:,1);
% g =a(:,:,2);
% b =a(:,:,3);
% d=0.33*(a(:,:,1)+a(:,:,2)+a(:,:,3));
subplot(2,2,2);
imshow(b);
% gaussian kernel
N = 5; %// Define size of Gaussian mask
sigma =2; %// Define sigma here
%// Generate Gaussian mask
ind = -floor(N/2) : floor(N/2);
[X Y] = meshgrid(ind, ind);
h = exp(-(X.^2 + Y.^2) / (2*sigma*sigma));
h = h / sum(h(:));
%// Convert filter into a column vector
h = h(:);
%// Filter our image
I_pad = padarray(b, [floor(N/2) floor(N/2)]);
C = im2col(I_pad, [N N], 'sliding');
C_filter = sum(bsxfun(@times, C, h), 1);
out = col2im(C_filter, [N N], size(I_pad), 'sliding');
subplot(2,2,3);
imshow(out);
out=out(:);
b=b(:);
l_p=xcorr(b,out);
subplot(2,2,4);
imshow(l_p);
Accepted Answer
More Answers (0)
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!