Problem with filtering an image
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rama Ratna
am 20 Okt. 2011
Kommentiert: Pallavi Bidri
am 19 Feb. 2019
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 Kommentar
Pallavi Bidri
am 19 Feb. 2019
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
Akzeptierte Antwort
Image Analyst
am 21 Okt. 2011
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 Kommentare
Image Analyst
am 21 Okt. 2011
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.
Weitere Antworten (2)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!