# how to change luminance level of binary image?

조회 수: 6 (최근 30일)
NIVETHA RAJENDRAN 2014년 1월 24일
편집: DGM 2022년 11월 13일
i=imread('aa1.jpg');
figure,imshow(i(:,:,1))
YCBCR = rgb2ycbcr(i);
figure,imshow(YCBCR);
lev=graythresh(i(:,:,1));
binimg=im2bw(YCBCR,lev);
figure;imshow(binimg)

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

### 답변 (2개)

Walter Roberson 2014년 1월 24일
rgbbinimg = repmat(double(binimg), [1 1 3]);
Now you can play with the rgb values associated with rgbbinimg
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

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

DGM 2022년 11월 13일
편집: DGM 2022년 11월 13일
The problem here is simple. You're calculating the threshold values from the luma channel (Y), but you're not thresholding the luma channel. Instead, you pass the entire YCbCr image to im2bw(). When im2bw() receives a 3-channel image, it assumes that it's RGB and does a RGB-Y transformation on it. In this case, the result is nonsense, since the input isn't RGB. It's YCbCr.
% you have an RGB image
RGB = imread('peppers.png');
% you turn it into a YCC image
YCBCR = rgb2ycbcr(RGB);
% if you pass im2bw() a 3-channel YCC image,
% it will internally create this nonsense image
imagethatgetsbinarized = rgb2gray(YCBCR);
% which looks like this
imshow(imagethatgetsbinarized)
That's the image that you're trying to binarize. A (typically) low-contrast image that's heavily weighted toward central gray values (due to the influence and symmetry of Cb,Cr). It's understandable that the threshold values calculated for this image
imshow(YCBCR(:,:,1))
... won't work well on the improperly-transformed image that's actually being used.
If you want to threshold on Y, pass Y to im2bw() (or imbinarize() in more modern versions).

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

### 카테고리

Help CenterFile Exchange에서 Image Type Conversion에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by