# bounjours a tous , alors j'ai commence de trvaille avec matlab j'ai esseye de faire le produit de convolusion entre une image et un filtre gaussian avec la fonction conv2 mais je suis bloqué a cause de ca voila l'erreur:N-D arrays are not supported.

6 views (last 30 days)
amal abbbes on 13 Feb 2018
Commented: amal abbbes on 17 Feb 2018
sigma1 = 1.9;
sigma2 =2.8;
hsize = [3,3];
h1 = fspecial('gaussian', hsize, sigma1);
h2 = fspecial('gaussian', hsize, sigma2);
% [a,b]=size(img);
% m1=max([a+3-1,a,3]);
% n1=max([b+3-1,b]);
% im1=cell(m1,n1);
im1=conv2(img,h1);
im2=conv2(img,h2);

Rik on 13 Feb 2018
Next time, use the {}Code button to format your code.
You did img=imread('image.jpg');, which results in a 3D matrix (column,row,color). You need to reduce that to two dimension, e.g. with img=imread('image.jpg');img=mean(img,3);.
amal abbbes on 17 Feb 2018
Here I want to created a single-line matrix and three columns with each box containing another matrix I want to stores the image in this sub matrix.so How I can solve the problem please

Image Analyst on 17 Feb 2018
You need to convert from color to gray scale and then cast the image to single or double before sending in to conv2().
Try this:
clc;
fontSize = 15;
% Display the image.
subplot(2, 3, 1);
imshow(rgbImage, []);
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Convert to gray scale.
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
% grayImage = rgb2gray(rgbImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
grayImage = rgbImage(:, :, 1); % Take red channel.
else
grayImage = rgbImage; % It's already gray scale.
end
% Display the image.
subplot(2, 3, 2);
imshow(grayImage, []);
title('Gray Scale Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Get the blur kernels.
sigma1 = 1.9;
sigma2 = 2.8;
windowSize = [3,3];
h1 = fspecial('gaussian', windowSize, sigma1);
h2 = fspecial('gaussian', windowSize, sigma2);
% Display the image.
subplot(2, 3, 3);
imshow(h1, []);
title('Blur Kernel 1 Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Display the image.
subplot(2, 3, 4);
imshow(h2, []);
title('Blur Kernel 2 Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
drawnow; % Force screen repaint right now.
% Blur the image.
im1 = conv2(double(grayImage), h1);
im2 = conv2(double(grayImage), h2);
% Display the image.
subplot(2, 3, 5);
imshow(im1, []);
title('Blurred Image 1', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Display the image.
subplot(2, 3, 6);
imshow(im2, []);
title('Blurred Image 2', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0.05, 1, 0.95]);
amal abbbes on 17 Feb 2018
it is as if Submatrix Nested in one each box of the matrice.I wants to create a matrix m (1, 3) which contains a single row and three columns and in each box of the matrix m, m (i, J) I want to create another m2 matrix of size (3.1) and then in Ach cell of the M2 matrix ,I want to store the image :pyramide de gaussaian how can i do it please

### Tags

No tags entered yet.

### Community Treasure Hunt

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

Start Hunting!

Translated by