Superimpose Image 1 onto bottom right of Image 2
Mostrar comentarios más antiguos
Hello,
I copy and pasted this pseudo code and tried to adjust it to my variables. I have "USI.png" and "FigIWant.png" both of which are saved as png. I am trying to put USI in the bottom right corner of FigIWant (sort of like a legend on a graph). Due to legal reasons, I am not allowed to post the figures I am working with, but I can provide the properties. I can offer a subsitute image if needed.
Figure (3: USl) with properties:
Number: 3
Name: 'Unscaled Color Wheel'
Color: [0.9400 0.9400 0.9400]
Position: [360 198 560 420]
Units: 'pixels'
Figure (6: FigIWant) with properties:
Number: 6
Name: 'Tissue-Velocity Segmented'
Color: [0.9400 0.9400 0.9400]
Position: [360 198 490.8000 370]
Units: 'pixels'
Here is the error msg:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right
side. Error in superimposeexample (line 26)
disp((1:size(obj,1))+rowshift, (1:size(obj,2))+colshift, :) = obj;
% Create the scene
% This example uses a random set of pixels to create a TrueColor image
scene = FigIWant;
% Create the object image
% This example uses a blend of colors from left to right, converted to a TrueColor image
% Use repmat to replicate the pattern in the matrix
% Use the "jet" colormap to specify the color space
obj = USI;
% Display the images created in subplots
hf2 = figure('units','normalized','position',[.2 .2 .6 .6]);
axi1 = subplot(2,3,1);
file1 = uigetfile('FigIWant.png');
axis off
title('Scene')
axi2 = subplot(2,3,4);
obj = uigetfile('USI.png');
axis off
title('Object image')
% Now replace pixels in the scene with the object image
result = scene;
% Define where you want to place the object image in the scene
rowshift = 20;
colshift = 0;
% Perform the actual indexing to replace the scene's pixels with the object
disp((1:size(obj,1))+rowshift, (1:size(obj,2))+colshift, :) = obj;
% Display the results
ax3 = subplot(2,3,[2:3, 5:6]);
iresult = image(result);
axis off
hold on
title(sprintf('Using indexing to overlay images:\nresult is one image object'))
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Images en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!