Making image transparent for overlaying

1 次查看(过去 30 天)
I have a couple of images that I am using the imregister function from the Image Processing Tool Box. I have it working great. However, in my two images, I have random spots of missing data. As a PNG, they are values of 0. I want to turn those 0 values into transparent images, so that when imregister overlays them correctly, I am essentially filling in the missing pixels from one image, with the filled pixels from the other.
I am searching for transparent images with MatLab, but I do not seem to be finding exactly what I need?

回答(1 个)

Walter Roberson
Walter Roberson 2013-8-28
im1 = image(YourUnderlayImage);
overlaymask = YourOverlayImage ~= 0; %0 being the marker for missing
im2 = image(YourOverlayImage, 'AlphaData', overlaymask );
Underlay will then be visible where-ever Overlay was 0.
  1 个评论
Image Analyst
Image Analyst 2020-5-4
img = imread('peppers.png');
subplot(3, 1, 1);
image(img);
axis('on', 'image');
title('Original Image');
YourOverlayImage = rgb2gray(img) > 100;
subplot(3, 1, 2);
imshow(YourOverlayImage);
axis('on', 'image');
title('Overlay Image');
subplot(3, 1, 3);
overlaymask = YourOverlayImage ~= 0; % 0 being the marker for missing
im2 = image(YourOverlayImage, 'AlphaData', overlaymask );
axis('on', 'image');
title('Original + Overlay Image');

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by