Blockproc, appdesigner, mutliple outputs (combined to one) returning empty
Show older comments
Is there a reason why blockproc isn't returning anything:
ax=app.UIAxes;
IM=getimage(ax);
border_size = [10 10];
block_size=[100 100];
%these are user supplied via editboxes
guess=app.FWHMguesspixelsEditField.Value;
[template]=255*getTemplateFromGuess(app,guess); %My own function
thresh=app.NXCThreshEditField.Value;
%Use blockproc to break up my large image into smaller ROI's
myfun = @(block_struct) app.myFindSpots(thresh,block_struct.data,template);
Centroids = blockproc(IM,block_size,myfun,"BorderSize",border_size)
returns with:
Centroids =
[]
where:
function [centroids] = myFindSpots(app,thresh,IM,template)
IM=im2double(IM);
try
c=normxcorr2(template,IM);
%Use regionpropos on c to get single representation (using weighted
%centroid. This prevents multiple representations of same object
GreaterThanThreshold = c > thresh;
s = regionprops(GreaterThanThreshold,c, 'WeightedCentroid');
centroids = cat(1, s.WeightedCentroid);
xpeak=centroids(:,1); ypeak=centroids(:,2);
%Account for padding
yoffSet = round((size(c,1)-size(IM,1))/2);
xoffSet = round((size(c,2)-size(IM,2))/2);
x1=xpeak-xoffSet; %now undo effect of padding as plotting on raw image
y1=ypeak-yoffSet;
catch
% Theres an error with finding spots
x1=NaN; y1=NaN;
end
centroids=[x1,y1]; %If I uncomment this, I see all the values are O.K
end
Accepted Answer
More Answers (0)
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!