Whats up folks I'm having a little problem in filtering this image: http://img15.imageshack.us/img15/9287/palhaco.png
The source code is bellow:
C = imread('Palhaco.png');
imshow(C);
figure;
g = fspecial('gaussian',15,2);
imagesc(g); colormap(gray);
surfl(g)
figure;
gC = convn(C,g,'same');
imshow(convn(C,[-1 1],'same'));
figure;
imshow(convn(gC,[-1 1],'same'));
figure;
dx = convn(g,[-1 1],'same');
imshow(convn(C,dx,'same'));
figure;
lg = fspecial('log',15,2);
lC = convn(C,lg,'same');
imshow(lC)
figure
imshow(C + .2*lC)
When I compile the program, It returns: "Integers can only be combined with integers of the same class, or scalar doubles."
I'm open to any idea at all!

댓글 수: 1

Pallavi Bidri
Pallavi Bidri 2019년 2월 19일
By using imtool function, check the class of both images that you want to combine.
If any image is of different class, convert it to any1 class to match with the other by using the command,
im2double(image) %converts given image to class double
im2uint8(image) % converts the given image to class uint8
generally, im2---(image) % dash after im2 can be the desired class that you want to be of

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2011년 10월 21일

0 개 추천

The code is very experimental so far. It seems like you're doing some experiments in trying to get rid of the pattern noise, but not doing a very good job of it (so far). Anyway, this will "fix" your code. It will at least run now without errors, and it does what you are telling it to do, even though that is kind of gibberish. As a bonus I put them all on one screen with titles above the images.
workspace; % Make sure the workspace panel is showing.
fontSize = 15;
% Read in original color image.
folder = 'C:\Documents and Settings\myUserName\My Documents\Downloads';
baseFileName = 'Palhaco.png';
fullFileName = fullfile(folder, baseFileName);
rgbImage = imread(fullFileName);
subplot(3, 3, 1);
imshow(rgbImage);
title('Original Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Get a convolution kernel.
g = fspecial('gaussian',15,2);
subplot(3, 3, 2);
imshow(g, []);
title('g - Gaussian Kernel', 'FontSize', fontSize);
subplot(3, 3, 3);
surfl(g)
title('g - Gaussian Kernel', 'FontSize', fontSize);
grayImage = rgbImage(:,:,2); % Get green channel.
gC = conv2(grayImage, g,'same');
subplot(3, 3, 4);
imshow(conv2(grayImage,[-1 1],'same'));
title('gC - Original Image Convolved with g', 'FontSize', fontSize);
subplot(3, 3, 5);
imshow(conv2(grayImage,[-1 1],'same'));
title('Original Image Convolved with [-1 1]', 'FontSize', fontSize);
subplot(3, 3, 6);
imshow(conv2(gC,[-1 1],'same'));
title('gC convolved with [-1 1]', 'FontSize', fontSize);
dx = conv2(g,[-1 1],'same');
subplot(3, 3, 7);
imshow(convn(grayImage, dx, 'same'));
title('dx', 'FontSize', fontSize);
lg = fspecial('log',15,2);
lC = conv2(grayImage, lg, 'same');
subplot(3, 3, 8);
imshow(lC)
title('lC', 'FontSize', fontSize);
subplot(3, 3, 9);
imshow(single(grayImage) + .2*lC);
title('single(grayImage) + .2*lC', 'FontSize', fontSize);

댓글 수: 3

Rama Ratna
Rama Ratna 2011년 10월 21일
Thx very much! But as you said, I'm trying to clean that image...
I ran ur code, and the results were not what I'm expecting...I need to filter that image...I know that the noise is caused by a periodic noise, and the final result must be a "clean" image. I thought in passing a notch filter and reject the frequencias of the periodic noise...But I dont have too much experience in matlab, so I'm stuck in that point. Have you any idea to my code or a new code?
Thanks so much for helping me, I'm really grateful.
Image Analyst
Image Analyst 2011년 10월 21일
I don't have time now. But the problem now is in your algorithm, not the MATLAB code, which I fixed. Do some research and try some things. Perhaps I'll get to it later.
Rama Ratna
Rama Ratna 2011년 10월 21일
Ok! I appreciate your attention, Thanks very much.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Rama Ratna
Rama Ratna 2011년 10월 21일

0 개 추천

On the other hand, I tried to pass a low-pass filter, but the results were not so good. Take a look:
sigma = 7;
h=fspecial('gaussian',[15, 15], sigma);
smoothedImage = imfilter(Image, h, 'same', 'conv');
The image obtained is kind of "clean" but blurred, is there any way to improve that?
Thx a lot
Rama Ratna
Rama Ratna 2011년 10월 21일

0 개 추천

I've already done it. Thanks for ur attention.

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

2011년 10월 20일

댓글:

2019년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by