I have a MATLAB code where I am generating a boundary figure for some word from an image.
This is then plotted using points generated from bwboundaries function and then I am using the generated plot to create an image that I am using later on in the code.
Here is the code snippet:
%GET 8-NEIGHBOURHOOD BOUNDARIES
[B,L,N] = bwboundaries(z,'noholes');
%PLOT THE BOUNDARY FIGURE FOR EACH WORD
figure;
hold on;
for k=1:length(B),
boundary = B{k};
if(k > N)
plot(boundary(:,2),boundary(:,1),'g','LineWidth',2);
else
plot(boundary(:,2),boundary(:,1),'r','LineWidth',2);
end
set(gca, 'visible', 'off');
F = getframe(gcf);
[X, Map] = frame2im(F);
end
Now, with a normal text with a slightly larger font size, I am getting perfect results, as expected. See here for proper output.
Now, the moment my font size is slightly smaller or the letters are a bit closely spaced, I find that the generated plot is somehow "squeezed" to fit the window size. See here for the wrong output.
I want the plot to take up as much space as it needs to show the entire boundary image, resizing itself if needed.
Otherwise, the frame2im is capturing the completely wrong image which is messing up my further computation.
EDIT
I must mention that the final plot figure is being formed by appending several smaller plots into one figure. This final plot is then being converted using frame2im.
As each smaller plot is being "appended", the rest of the image "squeezes" itself to make room for newer plots. Thus, the final image is totally squished together.
I thought that Adjusting size of plot in Matlab so that graph does not get cut off by edge of plot window was a possible duplicate, but in that particular case, the plot was getting truncated. In my case, I find the plot getting "squeezed" to fit the area.
print -dpng image.png; imread(image.png)- MZimmerman6frame2imcommand. I have never used it before, so I was unsure. just a guess :) - MZimmerman6