- don't save images by taking screenshots of the figure, unless you want the result to be arbitrarily resized and padded.
- don't save images as JPG, especially not for synthetic technical images -- especially not in MATLAB.
How to superimpose a segment image to original image?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
segment=imread('1.1.jpg');
original=imread('1.jpg');
I using
superimpose=imfuse(segment,original);
but it cant work, how can I place the segment img with transparency on top of original image?
0 comentarios
Respuestas (1)
DGM
el 12 de Oct. de 2024
This is what your label image looks like.
That's not useful as a label image anymore.
You can try to un-ruin it, but good luck.
% the images
BG = imread('1.jpg');
FG = imread('2.jpg');
% try to fix the fact that it's a padded screenshot
sza = size(BG,1:2); % we're lucky
p0 = [83 30];
FG = imcrop(FG,[p0 fliplr(sza)-1]);
imshow(imcomplement(FG))
% try to un-ruin everything done by JPG
FG = im2gray(FG); % get rid of unnecessary color
mk = FG < 230; % get rid of inverted background
mk = bwareaopen(mk,10); % try to get rid of artifacts
mk = ~bwareaopen(~mk,10); % try to get rid of artifacts
mk = bwmorph(mk,'open'); % try to fix broken edges
L = bwlabel(mk,4); % use 4-connectivity to avoid weak edges
% just throw together an overlay image
outpict = labeloverlay(BG,L);
imshow(outpict)
The result is still incomplete, since some of the small labeled regions are severely damaged or missing. Could it be improved? Probably, but the best way to fix a manufactured problem is to simply not create it. All this garbage could have been avoided by simply saving the original binary image or label array in a lossless format.
I know this example uses im2gray() and labeloverlay(), neither of which were available in 2015. I don't feel like playing time traveller tonight. I've posted plenty of examples that could replace im2gray(), and I believe I've done similar for the labeloverlay() composition task.
0 comentarios
Ver también
Categorías
Más información sobre 3-D Volumetric Image Processing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!