Issue with getframe and getimage commands while saving the image (image size mismatch).
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Preetham Manjunatha
am 6 Aug. 2017
Bearbeitet: Preetham Manjunatha
am 31 Jul. 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 Kommentare
Akzeptierte Antwort
Jan
am 6 Aug. 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Preview and Device Configuration finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!