MATLAB: Problem with filtering an image

clownconvconvolutiondigital image processingfigurefilterfilteringgaussianimageimage processingImage Processing Toolboxpalhaco

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!

Best Answer

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);