Image processing with sub images

8 views (last 30 days)
Hello guys here is my code. Here i created the subimages which carries 77x77 cell arrays i.e.. 5000 subimages appr. I attached my workspace for reference. In my code you can see i have a workflow. In this workflow am applying NLDoG filter to enhance my image in both freq and saptial level. Right now the variable Imgfft thats is my subimages converted to frequency domain(sfft is my function dont care abt it). In this loop am considering 6 subimages only in the 1st column(u see SubImage{1,f} and f=1:6). But what i want is to pass all the 77 images in the 1st column like the pair i created in variable name paiAvg. For example this for loop have to iterate at the begining 1 to 7 subimages and have store that result in variable refback, and then next 7 to 14 subimages and store that in same refback variable(like structure). like that upto 77 as i mentioned in the pairAvg.
refback = zeros(size(SubImage{1,1}));
pairAvg = {[1 7],[7 14],[14 22],[22 29],[29 36],[36 43],[43 50],[50 57],[57 64],[64 71],[71 77]};
for f = 1:6
Imgfft = sfft(SubImage{1,f});
[siz1,siz2] = size(Imgfft);
siz1;
siz2;
SpatDog = fspecial('gaussian',siz1,0.15) - fspecial('gaussian',siz2,0.24);%%0.5,0.8
FreqDog = sfft(SpatDog);
multip = abs(FreqDog).*Imgfft;
Y = isfft(multip);%ifft2(multip);
Z = (sigmf(Y, [NL 0])*2)-1;
Z = real(Z);
refback = refback + im2double(Z);
end
refback = (1/6) * refback;

Answers (1)

Sivani Pentapati
Sivani Pentapati on 30 Aug 2021
Based on my understanding, you want to iterate over the first column of subimages in the order provided by the pairAvg. One workaround would be to perform cell indexing and iterate over the pairAvg array. Attaching the updated code for your reference
refback = zeros(size(SubImage{1,1}));
pairAvg = {[1 7],[7 14],[14 22],[22 29],[29 36],[36 43],[43 50],[50 57],[57 64],[64 71],[71 77]};
for i =1:length(pairAvg)
for f = pairAvg{i}(1):pairAvg{i}(2)
Imgfft = sfft(SubImage{1,f});
[siz1,siz2] = size(Imgfft);
siz1;
siz2;
SpatDog = fspecial('gaussian',siz1,0.15) - fspecial('gaussian',siz2,0.24);%%0.5,0.8
FreqDog = sfft(SpatDog);
multip = abs(FreqDog).*Imgfft;
Y = isfft(multip);%ifft2(multip);
Z = (sigmf(Y, [NL 0])*2)-1;
Z = real(Z);
refback = refback + im2double(Z);
end
refback = (1/(pairAvg{i}(2)-pairAvg{i}(1)+1)) * refback;
end

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!