2d convolution

Thread Starter

teen devil

Joined Apr 6, 2009
47
HEY GUYS I AM TRYING TO CONVOLVE 2 IMAGES BUT THE MATLAB IS GIVING ME THE ERROR WHERE I AM USING CONV2 COMMAND ... HERE IS CODING
i1= imread('f.jpg')
i2=imread('ff.jpg')
c1 = conv2(i1,i2)
or
c1 = conv2(i1,i2,'valid')
both lines of c1 is not working
and the error is comming from line of c1...
I AM WAITING FOR UR HELP GUYS!!!
 

johndoe45

Joined Jan 30, 2010
364
i don't know. but i found something similar to this. and modified it to match yours. i'm guessing you just need an h matrix

clc
clear all
close all

A=imread('f.jpg');
B=imread('ff.jpg');
h = [0 1 0, 1 -4 1, 0 1 0];
A1=conv2(A:),:,1),h,'same');
A2=conv2(B:),:,2),h,'same');
A:),:,1)=A1;
A:),:,2)=A2;

subplot(121),imshow(A),title('image filtrée');
zoom on;

subplot(122),imshow(A),title('panchromatique filtrée');
zoom on;
 
Last edited:

Thread Starter

teen devil

Joined Apr 6, 2009
47
HEY BUT WHEN I CHANGED A TO B SO NOW COING BECOMES
clc
clear all
close all

A=imread('f.jpg');
B=imread('ff.jpg');
h = [1 2 1, 0 0 0, -1 -2 -1];
A1=conv2(A:),:,1),h,'same');
A2=conv2(B:),:,2),h,'same');
A:),:,1)=A1;
B:),:,2)=A2;

subplot(121),imshow(A),title('image filtrée');
zoom on;

subplot(122),imshow(A),title('panchromatique filtrée');
zoom on;
IT GIVES 2 IMAGES BUT WITH NO DIFFERENCE
 

johndoe45

Joined Jan 30, 2010
364
of course it gives you two images. i was just showing you that hey it works this way. i don't know what the code means. it was just to show you that it could be just that there is something wrong with the vectors. and h in previous made it work.

clc
clear all
close all

A=imread('f.jpg');
B=imread('ff.jpg');
C1=conv2(A:),:,1),B:),:,2),'same');

what does that do
 
Last edited:
Top