MATLAB: Overlay mask on sequence of mri images to mark out tumor ROI mri I created a mask based on one frame to mark out my ROI region. segment_mask = poly2mask(xi, yi, 256, 256); Is there a way I can overlay this mask onto my sequence of frames stored in a 3d array(256 x 256 x #of frames)? Best Answer maskedImg = imgArray.*segment_mask;% segment_mask is size [256,256]% maskedImg is same size as imgArray [256, 256, #of frames]If you are using an older version of Matlab you may have to use bsxfun(). Related SolutionsMATLAB: Store mask created from roipoly on scans running in for loop, in new variable You can store the mask in cell array and later call any mask as per requiremnets. n=?? % definemask=cell(1,n)for i=1:n %Mask generation, say mask_datamask{i}=mask_dataendNoy you can any mask as later say mask{1}, mask{2}, so on..... MATLAB: Create narrow band of pixels under gray region Threshold for black.mask = grayImage == 0;Extract the two largest regionsmask = bwareafilt(mask, 2);Then find the centroid or bounding boxprops = regionprops(mask, 'Centroid');and extract the lower black region. See if you can do this yourself.Call imerode() to shrink it. Then XOR the shrunken region with the original region to get just the edges.mask = imerode(lowerMask, true(9)); % Increase from 9 to get a wider white region.mask = xor(mask, lowerMask);Then set those pixels in the original image to white:grayImage(mask) = 255; Related QuestionIs masking,ROI and contour the sameHow to complete one of these two rectangles? I want to use it as mask for RGB image.Can I calculate the amount of black and white pixels inside a freehand region
Best Answer