필터 지우기
필터 지우기

Make an image darker with overlay of another image

조회 수: 4 (최근 30일)
Elena H.
Elena H. 2016년 6월 9일
편집: DGM 2024년 6월 4일
Hello,
I have two images I read into matrices that are displayed with imagesc. I was wondering if there's a way to darken one image using the other image (like I could in Photoshop by using the darken overlay feature). I've looked into a few options, like imfuse, but haven't had much luck. Any suggestions?

채택된 답변

Guillaume
Guillaume 2016년 6월 9일
If I understand correctly, darken just select whichever colour is darker in the two images, so it's simply:
darkenedimage = min(image1, image2);

추가 답변 (1개)

DGM
DGM 2024년 6월 4일
편집: DGM 2024년 6월 4일
If your images are in standard scale (i.e. correctly scaled for their class), then I don't see why you'd be using imagesc() to display them. If they're in some arbitrary scale, then directly comparing them might not make sense, but that would be a question for you to answer.
Assuming they're standard scale, then regardless of their class, MIMT imblend() can do most any blend operation offered by Photoshop/GIMP/Krita. That includes all the simple things like relational modes and basic arithmetic modes.
% two images of mixed class
BG = imread('peppers.png'); % uint8
FG = imcast(fliplr(BG),'int32'); % int32
% blend them
op1 = imblend(FG,BG,1,'lightenrgb');
op2 = imblend(FG,BG,1,'darkenrgb');
op3 = imblend(FG,BG,1,'lighteny');
op4 = imblend(FG,BG,1,'darkeny');
% make a montage in uint8
outpict = [imcast(FG,'uint8') BG; op1 op2; op3 op4];
imshow2(outpict)
It also includes all the other modes. In this case, 'darkeny' is comparable in concept to 'darker color'.
While imblend() is comprehensive in the modes it offers, if we consider the alternatives, it becomes noteworthy for perhaps the most absurdly mundane reasons. It's class and depth-agnostic, which isn't something you can get neatly using simple tools. Give it any two images with matching page geometry, and it will blend and composite them. So long as they're properly-scaled for their class, they can be of any numeric or logical class (except half-precision float).

Community Treasure Hunt

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

Start Hunting!

Translated by