2016-05-08 2 views
2

私はUWPウィンドウ10のアプリケーションでハイパスフィルタを適用しようとしています。まずはイメージをぼかしています。その後、元の画像からぼやけた画像を減算しています。私が持っている結果は、私がオンラインハイパスフィルタの異なる例を見てきたよう UWPでハイパスフィルタを適用するC#

enter image description here

のように、結果は私はこの使用してフォトショップを行っている。この

enter image description here

が好きすべきです。私は上記のアルゴリズムを適用した後にこの結果を得たいが、黒っぽい画像を得る。

私はthis articleに従っています。

答えて

1

あなたがしようとしていることを実装しようとしましたが、ありがたいことに、MATLABフォーラムから直接コードを取得しました。下の画像を見るとかなり良い結果を得ているようです。 enter image description here

私はあなたが欠けているものは画像を適切にグレースケールしていると思います。カラー画像にハイパスフィルタを直接適用し、グレースケール画像を期待していると思います。

また、実装したコードを共有して、最後に試してみることもできます。

clc; % Clear the command window. 
close all; % Close all figures (except those of imtool.) 
imtool close all; % Close all imtool figures. 
clear; % Erase all existing variables. 
workspace; % Make sure the workspace panel is showing. 
Image = imread('highPassFilter.jpg'); % Image from stack over flow 

%converting image to grayscale 
grayImage=rgb2gray(Image); 

% Get the dimensions of the image. numberOfColorBands should be = 1. 
[rows columns numberOfColorBands] = size(grayImage); 
% Display the original gray scale image. 
subplot(2, 2, 1); 
imshow(grayImage, []); 
title('Original Grayscale Image', 'FontSize', fontSize); 
% Enlarge figure to full screen. 
set(gcf, 'Position', get(0,'Screensize')); 
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off') 
% Filter 1 
kernel1 = -1 * ones(3)/9; 
kernel1(2,2) = 8/9 
% Filter the image. Need to cast to single so it can be floating point 
% which allows the image to have negative values. 
filteredImage = imfilter(single(grayImage), kernel1); 
% Display the image. 
subplot(2, 2, 2); 
imshow(filteredImage, []); 
title('Filtered Image', 'FontSize', fontSize); 
% Filter 2 
kernel2 = [-1 -2 -1; -2 12 -2; -1 -2 -1]/16; 
% Filter the image. Need to cast to single so it can be floating point 
% which allows the image to have negative values. 
filteredImage = imfilter(single(grayImage), kernel2); 
% Display the image. 
subplot(2, 2, 3); 
imshow(filteredImage, []); 
title('Filtered Image', 'FontSize', fontSize); 

私は役立つことを望みます。助けがあれば、アップヴォートするか、答えとして受け入れることを忘れないでください。

+0

答えをありがとう。私はこのMATLABコードを理解しています。私は自分のコードでそれをやろうとします。 C#またはjavaのコードを追加すると、私はあなたに感謝します。 –

+1

私はあなたのコードは、ハイパスフィルタに渡す前に画像をグレースケールで完全に細かいと思う。 – Mayank

関連する問題