the problem about use nlfilter
Show older comments
Hello, everyone
to imitate the demo from help and the demo from mathworks, I wrote the code about nlfilter.
%a gray level image using nlfilter function
A=imread('C:\Users\yanghang\Pictures\0.jpg');% get the image dimension
[rows,columns,numofColorBands]=size(A);
if numofColorBands >1 %not the gray image
grayimage=A(:,:,2) %Take Green channel
end
fun=@(x)median(x(:));% tell nlfilter to use function median to do its operation
doubleImage=im2double(grayimage);
B=nlfilter(grayimage,[3,3],fun); % filtering the image
subplot(1,3,1);
imshow(A);
subplot(1,3,2);
imshow(grayimage);
subplot(1,3,3);
imshow(B);
There is one thing troubles me. if I replace the first sentence with the second sentence
% doubleImage=im2double(grayimage);
doubleImage=double(grayimage);
I get two results. But in the workplace, the format is all double ,so why there are different?
Thanks in advance.
Hang Yang
Accepted Answer
More Answers (0)
Categories
Find more on 图像算术 in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!