Function for masking an image?

조회 수: 5 (최근 30일)
Ray
Ray 2014년 10월 20일
댓글: Image Analyst 2016년 7월 4일
function [masked] = maskImage(orig, mask)
Basically, this function takes a 3-D matrix (orig), and a 2-D logical mask matrix (mask) with the same number of rows and columns as the image matrix. This function should return an image matrix with the same dimensions as the original, where the original image colors show within the shape of the mask matrix and all other pixels are a quarter of their original intensity.
I'm having trouble with this since I am new to image processing and any help would be appreciated. Thank you.
  댓글 수: 2
Ravinder Kaur
Ravinder Kaur 2016년 7월 4일
Masking of segmented binary image with original image to get texture details...
I have used your code for masking, but i am not getting the same texture as in an original image...?? I am also getting some extra outliers in output image
Like you are getting same gray values in Circle_mask_demo.
Image Analyst
Image Analyst 2016년 7월 4일
Ravinder, post your code and image(s) in a new question.

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

답변 (1개)

Image Analyst
Image Analyst 2014년 10월 20일
See my demos, attached. They do just that. Let me know if you have any other questions. Be sure to check out my Image Segmentation Tutorial in my File Exchange. It's pretty much the essentials of what most image analysis boils down to: thresholding, labeling, calling regionprops. You may have to do a bunch of things to the image until you get to a point where something can be thresholded, and those operations are image-dependent.
  댓글 수: 3
Ray
Ray 2014년 10월 20일
I looked at the demos and they seem very advanced as compared to what I am trying to do. I know the outline of what I want to do but am having a hard time with the syntax etc. Basically, I am comparing the logical matrix to the input matrix. If the logical matrix at [1,1] is 1, then the masked matrix at [1,1] stays the same. But, if it is 0 at [1,1] then the masked matrix is divided by 4 at [1,1]. If you could help me with the syntax that would be great.
Image Analyst
Image Analyst 2014년 10월 20일
I thought my demos were all exceptionally well commented. Anyway, the line of code above will work for either gray level or RGB image. Can't get much simpler than one line of code. An alternative way for a gray scale image and that dividing by 4 things is:
grayImage(~mask) = grayImage(~mask)/4;

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by