bonjours, je veut calcule le pyramide de gaussian mais avant de faire ca j 'ai eliminé une partie de l'image avec la fonction imcrop le probleme réside lorsque je fait cette operation (suppresion de la partie de l'image) si non il y a pas une erreur

1 view (last 30 days)
tic
clear;
clc;
img=imread('img1.jpg');
[a,b,p]=size(img);
if p==3
img=rgb2gray(img);
end
IMG= imcrop(img,[1 1 660 578]);
[row colum]=size(img);
c=size(img,3);
[e d]=size(img);
%img=rgb2gray(img);
% img=histeq(img);
img=im2double(img);
origin=img;
% img=medfilt2(img);
toc
%%Scale-Space Extrema Detection
tic
% original sigma and the number of actave can be modified. the larger
% sigma0, the more quickly-smooth images
sigma0=sqrt(2);
octave=3;%6*sigma*k^(octave*level)<=min(m,n)/(2^(octave-2))
level=3;
D=cell(1,octave);
for i=1:octave
D(i)=mat2cell(zeros(row*2^(2-i)+2,colum*2^(2-i)+2,level),row*2^(2-i)+2,colum*2^(2-i)+2,level);
end
% first image in first octave is created by interpolating the original one.
temp_img=kron(img,ones(2,2));
temp_img=padarray(temp_img,[1,1],'replicate');
figure(2)
subplot(1,2,1);
imshow(origin)
%create the DoG pyramid.
for i=1:octave
temp_D=D{i};
for k=1:3
for j=1:level
scale=sigma0*sqrt(2)^(1/level)^((i-1)*level+j);
p=(level)*(i-1);
figure(1);
subplot(octave,level,p+j);
f=fspecial('gaussian',[7,7],scale);
L1=temp_img;
if(i==1&&j==1)
L2=conv2(temp_img,f,'same');
L2=conv2(L2,f','same');
temp_D(k,i,j)=L2-L1;
imshow(uint8(255 * mat2gray(temp_D(:,:,j))));
L1=L2;
else
L2=conv2(temp_img,f,'same');
L2=conv2(L2,f','same');
temp_D(:,:,j)=L2-L1;
L1=L2;
if(j==level)
temp_img=L1(2:end-1,2:end-1);
end
imshow(uint8(255 * mat2gray(temp_D(:,:,j))));
end
end
D{i}=temp_D;
temp_img=temp_img(1:2:end,1:2:end);
temp_img=padarray(temp_img,[1,1],'both','replicate');
end
end

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!