Image processing code explanation.

1 view (last 30 days)
lambda = 4;%8
theta = 0;
psi = [0 pi/2];
gamma = 0.5;
bw = 1;
N = 12;
bp_filter_input_image = sharpened_original_image;
bp_filtered_image = zeros(size(bp_filter_input_image, 1),
size(bp_filter_input_image, 2), N);
img_out_disp = zeros(size(bp_filter_input_image, 1),
size(bp_filter_input_image, 2), N);
% display 12 images in one window
figure;
for n=1:N
mean_filter = BP_fn(bw,gamma,psi(1),lambda,theta) +
1i * BP_fn(bw,gamma,psi(2),lambda,theta);
% filter output to the n-th channel
bp_filtered_image(:, :, n) = imfilter(bp_filter_input_image,
mean_filter, 'symmetric');
% next orientation
theta = theta + pi/N;
% default superposition method, L2-norm
image_vector = [];
image_vector = sum(abs(bp_filtered_image(:,:,n)).^2, 3).^0.5;
% normalize
img_out_disp(:,:,n) = image_vector./max(image_vector(:));
%result show
str=sprintf('BP theta=pi/%d',n);
subplot(3,4,n),imshow(img_out_disp(:,:,n));xlabel(str);
end
I have the following questions:
(1) What is the target/end-result of this entire routine?
(2) What is going on in the following line of code? What is 1i?
mean_filter = BP_fn(bw,gamma,psi(1),lambda,theta) +
1i * BP_fn(bw,gamma,psi(2),lambda,theta);
(3) What is going on in the following line of code?
image_vector = sum(abs(bp_filtered_image(:,:,n)).^2, 3).^0.5;
  2 Comments
Ba Ba Black Sheep!
Ba Ba Black Sheep! on 13 Feb 2017
Edited: Ba Ba Black Sheep! on 13 Feb 2017
function H = BP_fn(bw,gamma,psi,lambda,theta)
sigma = lambda/pi*sqrt(log(2)/2)*(2^bw+1)/(2^bw-1);
sigma_x = sigma;
sigma_y = sigma/gamma;
sz = fix(8*max(sigma_y,sigma_x));
if mod(sz,2)==0, sz = sz+1;end
[x y] = meshgrid(-fix(sz/2):fix(sz/2),fix(sz/2):-1:fix(-sz/2));
% Rotation
x_theta = x*cos(theta)+y*sin(theta);
y_theta = -x*sin(theta)+y*cos(theta);
H = exp(-0.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2))
.*cos(2*pi/lambda*x_theta+psi);
Mallikarjun umadi
Mallikarjun umadi on 3 Jan 2020
Edited: Mallikarjun umadi on 3 Jan 2020
can anyone suggest code for skin disease identification using matlab code?only for herpes, psoriasis and dermatitis

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 13 Feb 2017
According to the comments it displays 12 filtered images. Can't you ask the author? Why are you running code if you have no idea what it's supposed to do?
1i is the imaginary variable sqrt(-1).
The line of code:
image_vector = sum(abs(bp_filtered_image(:,:,n)).^2, 3).^0.5;
is a bit strange. bp_filtered_image(:,:,n) is a 2-D complex valued image. Then they take the square magnitude of it. Not sure why they're summing along the third dimension. Then they take the square root to get the magnitude of it, like you'd get from just using abs() or norm() I think.
I don't know what BP_fn() is since the code for that was not included.
  1 Comment
Ba Ba Black Sheep!
Ba Ba Black Sheep! on 13 Feb 2017
Edited: Ba Ba Black Sheep! on 13 Feb 2017
> Can't you ask the author?
I mailed the author and he doesn't respond.
> Why are you running code if you have no idea what it's supposed to do?
I am doing a thesis. Trying to understand this and some other parts of the source code so that I can use it in my own project.
> I don't know what BP_fn() is since the code for that was not included.
BP_fn() included.

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!