How invert only one colour in RGB image?

조회 수: 5 (최근 30일)
Pavel M
Pavel M 2022년 4월 4일
편집: Pavel M 2022년 4월 5일
Hello!
I want to change background in my rgb image from black to white. How I can do it without inversing others colours?
  댓글 수: 7
Pavel M
Pavel M 2022년 4월 4일
For the beginning i wanted to invert black to white.
For the second, after inverting i want to do numbers on scales x and y more clear
Pavel M
Pavel M 2022년 4월 4일
It is ideal variant

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

채택된 답변

DGM
DGM 2022년 4월 4일
The easy way to do this is L inversion. You can do this the hard way, or you can just use MIMT tools:
inpict = imread('scope.png');
outpict = imtweak(inpict,'hsl',[0 1 -1]); % invert L
imshow(outpict)
Of course yellow on white is hard to read, so desaturating might help.
inpict = imread('scope.png');
outpict = imtweak(inpict,'hsl',[0 0.7 -1]); % invert L, reduce S
imshow(outpict)
Otherwise, you could always try to mask off certain parts of the image and adjust them independently.
Imtweak() is part of MIMT, and is available at the link above.
  댓글 수: 5
DGM
DGM 2022년 4월 5일
I'm assuming you're after the floating toolbar things. This is one example. I can't really provide an example of the mask generation, since I did that by manual selection. I attached the mask image.
inpict = imread('scope.png');
% mask created by manual selection using immask() in HSV
mk = imread('scopemask.png');
mk = imfill(mk,'holes'); % fill in holes
% adjust the whole image
outpict = imtweak(inpict,'hsl',[0 0.7 -1]); % invert L, reduce S
% but use the mask to revert the selected areas
outpict = replacepixels(inpict,outpict,mk);
imshow(outpict)
Pavel M
Pavel M 2022년 4월 5일
편집: Pavel M 2022년 4월 5일
Nice! Thank you

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by