0

I need help for a function for filtering an image. I tried this:

originalImage = imread('A4.jpg');
n = 100;
resizedImage = imresize(originalImage, [n n]);

figure;
imshow(resizedImage);
title('Original Bild');

J = im2double(resizedImage);
h1 = [1 1 1; 1 -8 1; 1 1 1];
h2 = 1/16 * [1 2 1; 2 4 2; 1 2 1];
h3 = [1 2 1; 0 0 0; -1 -2 -1];

h1_180 = imrotate(h1, 180);
h2_180 = imrotate(h2, 180);
h3_180 = imrotate(h3, 180);
J1 = padarray(J,[1 1]);

for a =1:100
J2= J1.* h1;   
end

figure;
imshow(J2);
title('Faltung mit h1');    

This is not working. What do I need ?

jordiburgos
  • 5,964
  • 4
  • 46
  • 80
yascod
  • 13
  • 1
  • 5
  • Would i not speak german, i would have no idea what you are trying to do. But even when reading the last line, it's safe to say: this is way too broad and informal. Don't let others deduce what your code is trying to do. Explain the task formally, your approach and what's exactly the problem you observe! – sascha Nov 18 '17 at 18:31
  • From the help center: "Questions seeking debugging help (**"why isn't this code working?"**) must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a [MCVE]." – Sardar Usama Nov 18 '17 at 18:32
  • I would try to filtering a image without the matlab function `B = imfilter(A,h)`. I want to do it with a own function, but i don´t know how i can do that. I tried it with one loop but i think i need more loops or i did everything wrong, so i need help. Is this information enough? – yascod Nov 18 '17 at 18:38
  • I removed the `processing` tag since it is for the programming language called "Processing" and not a generic tag for questions that involve e.g. image processing. Please read the description of a tag before using it. – John Coleman Nov 18 '17 at 18:51
  • You're not doing any filtering at all. You're just doing element-wise multiplications. In any case, please consult the duplicate. You may use that code as it doesn't use any built-in functions for filtering. You will need to change the filter specification from a Gaussian to whatever filter you desire in your question. – rayryeng Nov 20 '17 at 20:56

0 Answers0