Issue with getframe and getimage commands while saving the image (image size mismatch).
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Preetham Manjunatha
le 6 Août 2017
Modifié(e) : Preetham Manjunatha
le 31 Juil 2021
Hello:
I have an issue while using getimage() command. I am trying to use a figure, first with imshow to initialize a color image (rgb from code) of size 1944x2592x3 pixels. After this, I want to overlay the bounding-boxes on the color image. I tried using getimage() to obtain the full-size image (1944x2592x3 pixels). It worked, but I am not getting the bounding-boxes overlaid image of full-size. Instead, I am getting a color image (rgb) of full-size.
If I use getframe(), I am getting the overlaid image but of smaller size. Anybody, please help me. I need the image(s) of the original size.
%% Matlab code used % Image overlay rgb = imoverlay(Igray, BW, [1 0 0]);
% Get bounding boxes coords st = regionprops(BW, 'BoundingBox' );
f = figure('Visible', 'off');
a = axes('Visible','off');
imshow(rgb);
hold on
for k = 1 : length(st)
thisBB = st(k).BoundingBox;
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)], EdgeColor','G','LineWidth',2 );
end
hold off
frame = getimage(f);
saving frame.cdata into a variable.
0 commentaires
Réponse acceptée
Jan
le 6 Août 2017
The problem is neither getframe not getimage, but rectangle: This function displays the rectangles on top of the image, but does not insert the pixel values into the image. If you take a screenshot afterwards by getframe, the rectangle are visible, but the resolution hast changed.
What you need is a tool to draw the rectangles into the RGB array directly. Then you do not need the indirection over the display in the figure. See https://www.mathworks.com/help/vision/ref/vision.shapeinserter-class.html and https://www.mathworks.com/help/vision/ref/insertshape.html
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Preview and Device Configuration dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!