필터 지우기
필터 지우기

Merge RGB image and grayscale image MATLAB

조회 수: 2 (최근 30일)
Penny
Penny 2017년 10월 24일
댓글: Penny 2017년 10월 26일
Hi Guys. I have a grayscale image with size of 256*256. Pixels are shown in black, white,gray. Now I want to make the center pixel to red, but other pixels remain the same to before. Anybody can help me?
Thanks a lot.

채택된 답변

Guillaume
Guillaume 2017년 10월 24일
rgbimage = repmat(yourgrayimage, [1 1 3]);
rgbimage(floor(end/2), floor(end/2), :) = [1 0 0]; %if image is of class double; [255 0 0] if uint8
  댓글 수: 3
Guillaume
Guillaume 2017년 10월 25일
What is the class of your original image, what is the range of gray values in that image, what exact code did you use to set that red pixel and what exact code are you using to display the image?
The result you show would happen if the range of grey values in your original image was 0-255 and yet your image was of type double (it should be uint8 if intensity range is 0-255) and you use plain imshow(rgbimage) to display the image.
If that is the case, then assign [255 0 0] to that centre pixel and use imshow(rgbimage, []).
Penny
Penny 2017년 10월 26일
Hello Guillaunme, I did it by using overlay code, because that is what I actually want. Thanks very much for your answer.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by