필터 지우기
필터 지우기

Masking images/matrixes

조회 수: 2 (최근 30일)
Amit Ifrach
Amit Ifrach 2023년 7월 14일
댓글: Image Analyst 2023년 7월 18일
לק"י
Hello!
I got an image of some stained cells:
And I have a grayscale mask such as this:
(different shades are covering different cells as you can see).
I want to systematically go through each gray shade in the mask and to extract (or leave) the area in the cells image.
I looked up for a quick command, but haven't found one.
I tried to use find command, but I get vectors as a result and can't use it to "talk" with the original image matrix.
This is the code I'm using:
img=imread("4.7.23 ut cd4_prfrn acd3+11002c3.tif");
mask=imread("4.7.23 ut cd4_prfrn acd3+11002c3_cp_masks.png");
i=max(max(mask))
maskx=[];
masky=[];
[maskx, masky]=find(mask==i);
imgmasked=img(maskxy,masky)
(I'm using a for loop to go through all indexes, but it will come later, I want to succeed masking right now)
What is the right way to handle this problem please?
Thanks,
Amit.
  댓글 수: 2
Jon
Jon 2023년 7월 14일
Please attach your two files
Amit Ifrach
Amit Ifrach 2023년 7월 15일
לק"י
Hi jon,
I added them. The cell's picture was converted from TIF to png.
Thanks!

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2023년 7월 14일
It looks like your mask is actually a labeled image since each blob seems to have a unique value (label). So in that case to get the area of each labeled blob you'd simply do
props = regionprops(labeledImage, 'Area');
allAreas = [props.Area] % Will give a vector of 5 areas.
  댓글 수: 5
Matt J
Matt J 2023년 7월 18일
Yes,
imgthldtmp=zeros(size(imgmask));
thldfnd= imgfltrd>(thldmltplr(k)*pxllstavg);
imgthldtmp(thldfnd)=imgfltrd(thldfnd);
Image Analyst
Image Analyst 2023년 7월 18일
Heck no. Shorter would be even more cryptic and hard to follow than it is now. No comments, cryptic variable names, etc. I don't know what you did but whatever, if it works for you, fine.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by