apply multiple circular masks on a diffractogram

10 visualizzazioni (ultimi 30 giorni)
hi,
I am trying to process the attached image: my aim is to select the spots (brighter spots for example) seen in the image manually and filter them out using a circular mask. I use ginput to select the spots. I can filter a single spot easily however i cannot make my code so that I can place the multiple masks. I try to this with loop and it did not work. I would appreciate any suggestion how to mask more than one spots.
this is the code for single spot masking
clear all close all
pwd
dp=imread('012_02.tif'); dp=dp([2:126],[2:126]);
X=-62:1:62 %mesh size in X Y=-62:1:62 %mesh size in Y %grid for mask [x y]=meshgrid(X,Y); % for Camera
figure('Name', 'Center of Ronchi'); set(gcf, 'Position', get(0,'Screensize')); imshow(dp); prompt = 'select the center of Ronchi and click ENTER'; [pos]=ginput; [rows columns] = size(pos) r=row
o(1)=subplot(1,2,1); imshow(dp,'parent',o(1)); title('total');
hold(imgca,'on') plot(imgca,pos(:,1), pos(:,2), 'ro') hold(imgca,'off')
o(2)=subplot(1,2,2); imshow(dp,'parent',o(2));title('filtered');
hold(imgca,'on') plot(imgca,pos(:,1), pos(:,2), 'ro') hold(imgca,'off')
if pos(1)>max(X); xoff=x+(max(X)-pos(1)); else xoff=x+(-max(X)+pos(1)); end if pos(2)>max(Y) yoff=y+(max(Y)-pos(2)); else yoff=y+(-max(Y)+pos(2)); end
Dsize=5 %size of a mask
Diff_select = ((xoff).^2+(yoff).^2 < Dsize.^2) %mask centered on the selected spot
Detector1=double(dp).*Diff_select; %Masked image
imshow(Detector1);
I tried to do looping without success.
for i = 1 :r
if pos(i,1)>max(X); xoff=x+(max(X)-pos(i,1)); else xoff(i)=-pos(i,1); end
if pos(i,2)>max(Y) yoff=y+(max(Y)-pos(i,2)); else yoff(i)=pos(i,2); end
end

Risposta accettata

E. Yucelen
E. Yucelen il 9 Gen 2017
Modificato: E. Yucelen il 9 Gen 2017
ok. after manipulating arrays and cell arrays, I was able to get masks as I wanted
bb1=cell2mat(bb); aa1=cell2mat(aa); %convert cells to array
[rows2 columns2] = size(aa1); r=rows2 c=columns2
for i=0:r1-1
cc=aa1(1:r,(r*i+1):r*i+r); %extract right part of the array for mask operation
dd=bb1(1:r,(r*i+1):r*i+r);%extract right part of the array for mask operation
figure(1+i); %create displays
xxx=(cc+dd)<5; %make circular maps
counter=counter+xxx %sum individual masks into a single array
imshow(counter);
end

Più risposte (0)

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by