Best Variable Type to Store and Plot Multiple Images Obtained with Regularized Filtering
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello.
I've recently started using MATLAB and the Im. Proc. Toolbox to perform some basic image adjustment routines. Right now I'm interested in restoring a blurred, noisy image via regularized filtering using the deconvreg command. Specifically, I want to create a loop to process the same image with deconvreg three times, and in each iteration I want to use a different noise power value np. Since I've only recently started using MATLAB, I'm not sure which variable type I should use to store the three processed images, though cell arrays and structures seem to be good candidates from what I've read thus far. I'm also having trouble in implementing a for loop to implement this repeated use of deconvreg. Here's the code that I used to try the cell array approach:
np = [0.7, 0.8, 0.9]; %Noise power values to be used.
images = {};
for n = np(:)
frest = deconvreg(blurred_noisy, PSF, noisePower); %blurred_noisy is the image; PSF is set beforehand, too.
images{find(n==np),1} = frest; %Attempt at creating a cell array to store processed images. Does not work.
end
figure
for k = 1:3 %Attempt at plotting the three processed images.
subplot(1,3,m)
imshow(images{m})
end
Note that blurred_noisy is a double-type image with three channels (size 720x1082x3).
My question is: How can I set up a functioning for loop and what variable type should I use to store the three images? I realize that these are actually two questions, but I think it's reasonable to ask both in the same post because they're closely related.
Thanks in advance!
댓글 수: 0
답변 (1개)
Hiro Yoshino
2022년 9월 14일
When the images you are storing in a variable are consistent size-wise, a standard array is good enough.
Imagine that your image is [256 x 256 x 3] and you have n images, then the the array that stores your images wil be [256 x 256 x 3 x n].
Cell is used to accomodate multiple variables with different sizes and different types in a single cell, and thus this is very flexible. However, dealing with cell is a bit tricker than array, table, ... and other containers that have consistent variables in themselves.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!