Does regionprops function work in Matlab App designer
古いコメントを表示
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?
採用された回答
その他の回答 (1 件)
Matt J
2022 年 3 月 7 日
0 投票
The reason is that your bw is all zeros. Nothing to do with app designer.
カテゴリ
ヘルプ センター および File Exchange で Region and Image Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!