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!