kuwahara filter
来源:互联网 发布:淘宝工装鞋店铺推荐 编辑:程序博客网 时间:2024/05/22 17:42
RGB = imread('pic\2.jpg');
labimg = RGB2Lab(RGB);
% J = imnoise(I,'gaussian',0,0.005);
winsize=5;
Y1 = kuwahara(labimg(:,:,1),winsize,true);
Y2 = kuwahara(labimg(:,:,2),winsize,true);
Y3 = kuwahara(labimg(:,:,3),winsize,true);
[width,height,channel]=size(RGB);
PADDING = floor(winsize/2);
resut=zeros(width+PADDING,height+PADDING,channel);
resut(:,:,1)=Y1;
resut(:,:,2)=Y2;
resut(:,:,3)=Y3;
img=Lab2RGB(resut);
figure,imshow(RGB);
figure,imshow(img);
function [Y,Xpad] = kuwahara(X,WINSZ,progress)
% [Y,Xpad] = KUWAHARA(X[,WINSZ][,progress])
% perform kuwahara nonlinear edge-preserving filtering on an intensity
% image
%
% * If no window size WINSZ is specified, the default is 5.
% * Setting progress to a nonzero value causes KUWAHARA to display
% the current row it is processing.
%
% Description:
% The Kuwahara filter works on a window divided into 4 overlapping
% subwindows (typically 5x5 pixels, see below). In each subwindow, the mean and
% variance are computed. The output value (located at the center of the
% window) is set to the mean of the subwindow with the smallest variance.
%
% ( a a ab b b)
% ( a a ab b b)
% (ac ac abcd bd bd)
% ( c c cd d d)
% ( c c cd d d)
%
% Notes:
% Image is converted to double format for processing.
%
% References:
% http://www.incx.nec.co.jp/imap-vision/library/wouter/kuwahara.html
%
% Copyright Art Barnes, 2005 artbarnes<at>ieee<dot>org
if nargin >= 3
verboseFlag = true;
else
verboseFlag = false;
end
if nargin < 2
WINSZ = 5;
end
if ~isa(X,'double')
X = im2double(X);
end
PADDING = floor(WINSZ/2);
Xpad = padarray(X,[PADDING PADDING],'replicate');
[padRows,padCols] = size(Xpad);
Y = X;
nRowIters = length((PADDING+1):(padRows-PADDING));
count = 1;
iterations=3;
for m=1:iterations
for i = (PADDING+1):(padRows-PADDING)
for j = (PADDING+1):(padCols-PADDING)
% window & subwindows
W = Xpad((i-PADDING):(i+PADDING),(j-PADDING):(j+PADDING));
Wnw = W(1:(PADDING+1),1:(PADDING+1));
Wne = W(1:(PADDING+1),(PADDING+1):WINSZ);
Wsw = W((PADDING+1):WINSZ,1:(PADDING+1));
Wse = W((PADDING+1):WINSZ,(PADDING+1):WINSZ);
% find the variances
s = var([Wnw(:) Wne(:) Wsw(:) Wse(:)]);
m = mean([Wnw(:) Wne(:) Wsw(:) Wse(:)]);
[y,k] = min(s);
% assign the mean of the subwindow with the least variance to
% the center pixel
Y(i,j) = m(k);
end
if verboseFlag
fprintf('Kuwahara: %d/%d\n',count,nRowIters);
count = count + 1;
end
end
Xpad = padarray(Y,[PADDING PADDING],'replicate');
end
- kuwahara filter
- kuwahara filter 实现
- Kuwahara filter (python版)
- Shader特效——“Kuwahara Filter”的实现 【OpenCV】【GLSL】
- Kuwahara滤波
- Generalized Kuwahara (python版)
- Filter
- Filter
- Filter
- filter
- filter
- Filter
- filter
- Filter
- filter
- filter
- Filter
- Filter
- 查询下载专利方法
- 基于微云游戏引擎的游戏开发——《猴子跳》
- 2009年校园招聘笔试题-杭州(2)
- 《Oracle编程艺术》学习笔记(31)-什么情况下适合使用B*树索引
- Wac应用程序开发环境搭建(4Tizen)
- kuwahara filter
- java中计算对象内存大小
- 助你解决ie8与iis的兼容问题
- 业务&系统的生态环境
- Rational Rose 2003 之“Rational License key error”问题的解决方案
- OpenCV学习笔记(二)——新版本模块结构
- (转)[程序员]多些时间思考 少写些代码
- 如何判断一个指定的经纬度点是否落在一个多边形内
- 单位换算 Delphi示例