Does regionprops function work in Matlab App designer
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
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? 
댓글 수: 0
채택된 답변
  Simon Chan
      
 2022년 3월 7일
        You are extracting something less than or equals to the lower bound (example < 100), and then extracting the resulting image with pixel greater than or equals to upper bound (example > 200).  Then there is nothing left.
Modify the following
mriadjust(mriadjust <= lb) = 0; % segment out pixels w/ intensities lower than ub
mriadjust(mriadjust >= ub) = 0; % segment out pixels w/ intensities greater than lb
to
mriadjust(mriadjust <= ub) = 0; % segment out pixels w/ intensities lower than ub
mriadjust(mriadjust >= lb) = 0; % segment out pixels w/ intensities greater than lb
댓글 수: 0
추가 답변 (1개)
  Matt J
      
      
 2022년 3월 7일
        The reason is that your bw is all zeros. Nothing to do with app designer.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


