2016년 8월 30일 화요일

[Octave] Color Homomorphic Filtering

clear
close all
clc

pkg load image

I = imread('image16.jpg');

I = im2double(I);
%figure(2);imshow(rgb2gray(I))
rr=I(:, :, 1);
gg=I(:, :, 2);
bb=I(:, :, 3);

% Make Log
I = log(1 + I);

% mesh for H
M = 2*size(I,1) + 1;
N = 2*size(I,2) + 1;
sigma = 5;
[X, Y] = meshgrid(1:N,1:M);
centerX = ceil(N/2);
centerY = ceil(M/2);
gaussianNumerator = (X - centerX).^2 + (Y - centerY).^2;

H = 0.7*exp(-gaussianNumerator./(2*sigma.^2));
H = 1 - H + 0.9;
H = fftshift(H);

% fft fo image
rf = fft2(rr, M, N);
gf = fft2(gg, M, N);
bf = fft2(bb, M, N);

% product
rout = real(ifft2(H.*rf));
gout = real(ifft2(H.*gf));
bout = real(ifft2(H.*bf));

rout = rout(1:size(I,1),1:size(I,2));
gout = gout(1:size(I,1),1:size(I,2));
bout = bout(1:size(I,1),1:size(I,2));
% -1
rhm = exp(rout) - 1;
ghm = exp(gout) - 1;
bhm = exp(bout) - 1;

cc(:,:,1)= rhm;
cc(:,:,2)= ghm;
cc(:,:,3)= bhm;

subplot(1, 2, 1);imshow(I)
subplot(1, 2, 2);imshow(cc)


댓글 없음:

댓글 쓰기

gpustat command

sudo apt install gpustat watch --color -n0.1 gpustat --color