Make an image darker with overlay of another image
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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);
0 个评论
更多回答(1 个)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1708831/image.png)
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).
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!