getframe – different output on different computers (using plot)
Hi!
I’m creating a program where i want to draw a kind of hourglass shape and then save this as a binary image. This shape is to be drawn based on coordinates from an image. The problem I have come across is that the thickness of the drawn shape in the output image (binaryThinLine below) differs depending on which computer I run it on. I believe that the problem occurs when I save it using getframe, but I am not sure.
This is the code I’m using:
set(groot, ‘defaultFigureUnits’, ‘pixels’);
set(groot, ‘defaultFigurePosition’, [100 100 480 853]);
set(groot,’defaultFigureVisible’,’off’);
figure
imshow(frame)
hold on;
plot(x, y, ‘b’, ‘LineWidth’, thickness_black, ‘LineJoin’, ‘miter’, ‘Color’, [0 0 1 0.25]); % Plot outline with blue color and thicker line width
hold off;
% Choosing axes
xlim([0, width(frame)]);
ylim([0, height(frame)]);
axis off;
thinLineFrame = getframe(gca);
[thinLineImage, Map] = frame2im(thinLineFrame);
thinLineImage_blue = thinLineImage(:,:,1);
binaryThinLine = imbinarize(thinLineImage_blue, 0.9); % Creating a binary image.
%binaryThinLine=imresize(binaryThinLine,[480 853]);
When defaultFigureVisible is set to off, binaryThinLine becomes the same size on both computers. However, when it is set to on, they become different sizes and have to be resized.
So, my question is: how can I make sure that binaryThinLine keeps the same thickness on both computers, while also having the same dimension (480×853)? Thank you in advance!Hi!
I’m creating a program where i want to draw a kind of hourglass shape and then save this as a binary image. This shape is to be drawn based on coordinates from an image. The problem I have come across is that the thickness of the drawn shape in the output image (binaryThinLine below) differs depending on which computer I run it on. I believe that the problem occurs when I save it using getframe, but I am not sure.
This is the code I’m using:
set(groot, ‘defaultFigureUnits’, ‘pixels’);
set(groot, ‘defaultFigurePosition’, [100 100 480 853]);
set(groot,’defaultFigureVisible’,’off’);
figure
imshow(frame)
hold on;
plot(x, y, ‘b’, ‘LineWidth’, thickness_black, ‘LineJoin’, ‘miter’, ‘Color’, [0 0 1 0.25]); % Plot outline with blue color and thicker line width
hold off;
% Choosing axes
xlim([0, width(frame)]);
ylim([0, height(frame)]);
axis off;
thinLineFrame = getframe(gca);
[thinLineImage, Map] = frame2im(thinLineFrame);
thinLineImage_blue = thinLineImage(:,:,1);
binaryThinLine = imbinarize(thinLineImage_blue, 0.9); % Creating a binary image.
%binaryThinLine=imresize(binaryThinLine,[480 853]);
When defaultFigureVisible is set to off, binaryThinLine becomes the same size on both computers. However, when it is set to on, they become different sizes and have to be resized.
So, my question is: how can I make sure that binaryThinLine keeps the same thickness on both computers, while also having the same dimension (480×853)? Thank you in advance! Hi!
I’m creating a program where i want to draw a kind of hourglass shape and then save this as a binary image. This shape is to be drawn based on coordinates from an image. The problem I have come across is that the thickness of the drawn shape in the output image (binaryThinLine below) differs depending on which computer I run it on. I believe that the problem occurs when I save it using getframe, but I am not sure.
This is the code I’m using:
set(groot, ‘defaultFigureUnits’, ‘pixels’);
set(groot, ‘defaultFigurePosition’, [100 100 480 853]);
set(groot,’defaultFigureVisible’,’off’);
figure
imshow(frame)
hold on;
plot(x, y, ‘b’, ‘LineWidth’, thickness_black, ‘LineJoin’, ‘miter’, ‘Color’, [0 0 1 0.25]); % Plot outline with blue color and thicker line width
hold off;
% Choosing axes
xlim([0, width(frame)]);
ylim([0, height(frame)]);
axis off;
thinLineFrame = getframe(gca);
[thinLineImage, Map] = frame2im(thinLineFrame);
thinLineImage_blue = thinLineImage(:,:,1);
binaryThinLine = imbinarize(thinLineImage_blue, 0.9); % Creating a binary image.
%binaryThinLine=imresize(binaryThinLine,[480 853]);
When defaultFigureVisible is set to off, binaryThinLine becomes the same size on both computers. However, when it is set to on, they become different sizes and have to be resized.
So, my question is: how can I make sure that binaryThinLine keeps the same thickness on both computers, while also having the same dimension (480×853)? Thank you in advance! image processing MATLAB Answers — New Questions