Denoising fails due to "array dimensions must match binary array op". Picture is 500x500 pixels even.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan Harris
am 16 Apr. 2019
Kommentiert: Jonathan Harris
am 17 Apr. 2019
img = im2double(imread('circuitboardN.jpg'));
imgfft = fftshift(fft2(img));
H5 = zeros(500,500); H15 = H5; H30 = H5; H80 = H5; H230 = H5;
x = 500; y = 500; cx = x/2; cy = y/2;
for i=1:x;
for j=1:y;
D(i,j) = sqrt([i-cx]^2 + [j-cy]^2);
end
end
H5 = exp(-.5*[D/5].^2); H15 = exp(-.5*[D/15].^2);
H30 = exp(-.5*[D/30].^2); H80 = exp(-.5*[D/80].^2);
H230 = exp(-.5*[D/230].^2);
h5 = abs(ifft2(H5.*imgfft)); h15 = abs(ifft2(H15.*imgfft));
h30 = abs(ifft2(H30.*imgfft)); h80 = abs(ifft2(H80.*imgfft));
h230 = abs(ifft2(H230.*imgfft));
figure;
subplot(3,2,1); imshow(imscale01(img)); subplot(3,2,2); imshow(imscale01(h5));
subplot(3,2,3); imshow(imscale01(h15)); subplot(3,2,4); imshow(imscale01(h30));
subplot(3,2,5); imshow(imscale01(h80)); subplot(3,2,6); imshow(imscale01(h230));
2 Kommentare
Walter Roberson
am 16 Apr. 2019
Is it truly a grayscale jpg? 99.999% of jpg are rgb even if they look grayscale.
Akzeptierte Antwort
Walter Roberson
am 17 Apr. 2019
That .jpg is RGB even though it looks gray. You need to use rgb2gray() on it before you can process it with that code.
I have only ever encountered approximately 5 real grayscale JPEG images, over several decades. All of the rest were either RGB images that looked gray (mostly) or simple demonstrations that it really was possible to create a grayscale JPEG. Grayscale JPEG exist, but four leafed clovers are more common.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!