Function for masking an image?
조회 수: 5 (최근 30일)
이전 댓글 표시
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
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.
답변 (1개)
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
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 Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!