Does regionprops function work in Matlab App designer
Afficher commentaires plus anciens
mriadjust = app.mri; % create a copy of the dataset
ub = app.upper_bound;
lb = app.lower_bound;
l=repmat(int16(0), [256 256 20]);
mriadjust(mriadjust <= lb) = 0; % segment out pixels w/ intensities lower than ub
mriadjust(mriadjust >= ub) = 0; % segment out pixels w/ intensities greater than lb
bw = logical(mriadjust); %binary conversion
%morphological opening
nhood = ones([7 7 3]);
bw = imopen(bw,nhood);
%isolate the largest region
l = bwlabeln(bw); %label the objects in the image
stats = regionprops(l,'Area','Perimeter'); %use the regionprops function to gather info on the objects
A = [stats.Area]; % copy the area informaton about the objects to the variable A
biggest = find(A == max(A)); % find the object with the largest area in the image
stats.Area
stats.Perimeter
mriadjust(l ~= biggest) = 0; % any object that is not the largest object gets removed
imA = imadjust(mriadjust(:,:,10));
figure
imshow(imA);
/////////////////////
Above is my code for segmenting MRI brain scans. I'm trying to implement the code into app designer but it always gives me the error array sizes don't match for ~= operation. I figured out it was because there was no values in my stats, A, or biggest variables. I suspect it is because regionprops is not working in the appdesigner. Is there a way around this?
Réponse acceptée
Plus de réponses (1)
Matt J
le 7 Mar 2022
0 votes
The reason is that your bw is all zeros. Nothing to do with app designer.
Catégories
En savoir plus sur Region and Image Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!