grayscale image problem in matlab

2 visualizaciones (últimos 30 días)
cyrine tijani
cyrine tijani el 19 de Abr. de 2021
hi i work with this code
J=handles.o;
[n m]=size(J)
% parameters settings
filter_family = 'DOP';
ratio = .98;
lambda = 5;
parameters = [lambda, ratio]
lambda = parameters(1);
ratio = parameters(2);
filter_parameters = [lambda, ratio ];
orient_mode = 'robust';
freq_mode = 'robust';
parms = struct('filter_family',filter_family,...
'filter_parameters',filter_parameters,...
'orient_mode',orient_mode,...
'freq_mode',freq_mode,'sigma',.5);
% Calcul de la représentation fréquentille d'un filtre en Quadrature (HR1 et HR2)
[sx,sy]=size(J)
sze=[sx,sy]
if sx == 1
sx = sy;
sy = 1;
end
if mod(sx,2)
yrange = ((-(sx-1)/2:(sx-1)/2))/(sx-1);
else
yrange = (-sx/2:(sx/2-1))/sx;
end
if sy == 1
u1 = xrange;
u2 = 1;
radius = abs(ifftshift(u1)); % Quadrant shift to put 0 frequency at the corners
radius(1,1) = 1;
lp = 1;
HR1 = ( 1i*u1)./radius;
HR2 = (1i*u2)./radius;
else
if mod(sy,2)
xrange = (-(sy-1)/2:(sy-1)/2)/(sy-1);
else
xrange = (-sy/2:(sy/2-1))/sy;
end
[u1,u2] = meshgrid(xrange, yrange);
u1 = ifftshift(u1); % Quadrant shift to put 0 frequency at the corners
u2 = ifftshift(u2);
radius = sqrt(u1.^2 + u2.^2);
%radius(1,1) = 1;
HR1 = ( 1i*u1)./radius;
HR2 = ( 1i*u2)./radius;
% Calcul de filtre pass bas
[sx,sy]=size(J)
sze = [sx,sy]
cutoff = .4
n =10
if cutoff < 0 | cutoff > 0.5
error('cutoff frequency must be between 0 and 0.5');
end
if rem(n,1) ~= 0 | n < 1
error('n must be an integer >= 1');
end
if length(sze) == 1
rows = sze; cols = sze;
else
rows = sze(1); cols = sze(2);
end
% Set up X and Y matrices with ranges normalised to +/- 0.5
% The following code adjusts things appropriately for odd and even values
% of rows and columns.
if mod(cols,2)
xrange = [-(cols-1)/2:(cols-1)/2]/(cols-1);
else
xrange = [-cols/2:(cols/2-1)]/cols;
end
if mod(rows,2)
yrange = [-(rows-1)/2:(rows-1)/2]/(rows-1);
else
yrange = [-rows/2:(rows/2-1)]/rows;
end
[x,y] = meshgrid(xrange, yrange);
radius = sqrt(x.^2 + y.^2); % A matrix with every pixel = radius relative to centre.
lp = ifftshift( 1.0 ./ (1.0 + (radius ./ cutoff).^(2*n)) ); % The filter
end
% Calcul de filtre de log-Gabor (H)
lambda = parameters(1);
ratio = parameters(2);
if ratio >= 1
error('ratio must be smaller than 1 !!!')
end
s2 = lambda/(2*pi*(ratio-1))*log(ratio);
s1 = ratio*s2;
DoP = exp(-2*pi*radius*s1) - exp(-2*pi*radius*s2);
DoP = DoP.*lp;
DoP(1,1) = 0;
H = DoP;
% Calcul des filtres en quadrature
IM = fft2(J);
IM=double(IM);
[n,m]=size(IM)
clear im
% Calcul de w et q (les compsantes de signal monogénique)
w = real(ifft2(H.*IM)) % Even component
q1 = ifft2 (imag(HR1.*H.*IM));
q2 = ifft2(imag(HR2.*H.*IM));
fM.w = w; % Even component
fM.q1 = q1;
fM.q2 = q2;
q= sqrt(q1.^2 + q2.^2)% Odd component
%%% orientation computation
if strcmp(parms.orient_mode,'robust')
s = parms.sigma;
x = -floor(4*s):floor(4*s);
w1 = exp(-x.^2/(s/2)); w1 = w1./sum(w1(:));
else
w1 = 0;
end
% calcul de cosinus et sinus
w1 = w1(:);
f1 = real(q);
f2 = imag(q);
J11 = f1.^2;
J12 = f1.*f2;
J22 = f2.^2;
clear f1 f2
N = floor(numel(w1)/2);
J11 = conv2(w1,w1',padarray(J11,[N N],'symmetric'),'valid');
J12 = conv2(w1,w1',padarray(J12,[N N],'symmetric'),'valid');
J22 = conv2(w1,w1',padarray(J22,[N N],'symmetric'),'valid');
theta = 1/2*atan2(2*J12,J22-J11)
sinus = cos(theta);
cosinus = sin(theta);
% extraction des paramètres
A = sqrt(w.^2 + abs(q1).^2 +abs(q2).^2); % enveloppe
% Affichage des images de phase et amplitude monogénique
feats = struct('A',A);
axes(handles.axes7);
imagesc(feats.A);
colorbar
title('\color{white}MONOGENIC Amplitude end diastolic','fontsize',12),
set(gca,'Xtick',[])
set(gca,'Ytick',[])
at first i display an image then i apply this code on it , it was supposed to give me an image with colors like in the first photo bellow but it gaves me a grayscale image
NB: if i show it in a figure it works but when i put in an axes it doesn't work
any help please ?

Respuestas (0)

Categorías

Más información sobre Signal Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by