Why is the entire image copied instead of the axes only?
3 views (last 30 days)
What I have is a plot showing the area of connected components. What I want to do is to further work on the plot figure such as clean it up a bit or ``imcomplement`` it etc. and then be able to apply the axes from the original plot to this image and be able to extract the ``ylabel``.
Let me explain the above issue with my code and some examples.
This is the plot I have, the y-axis represents the object areas. This is the important axis that I want to transfer to the new image.
Since I am interested in the axes only I copy that using
h = findobj(gcf,'type','axes');
So that I can work with the figure without the axes and borders interfering I save it without these attributes
set(gca, 'visible', 'off'); % Hide the axis and borders
hgexport(gcf, 'plot1.jpg', hgexport('factorystyle'), 'Format', 'jpeg');
This is what I get:
So far so good.
Now comes the processing or in other words changing the plot to my needs.
plot_img = rgb2gray(imread('plot1.jpg'));
img_bw_plot = im2bw(plot_img, graythresh(plot_img));
[rows cols] = size(plot_img);
new = zeros(size(plot_img));
for i = 1: rows
for j = 1: cols
if (img_bw_plot(i,j) == 0)
new(i, 1:10) = 255;
f = figure;
This produces a weird overlapped image where instead of copying only the axes, the entire image is copied on top of the ``new``. The ``datacursormode`` also fails to work beyond the over lapping image.
Image Analyst on 17 Mar 2014
I really don't understand what you want to do. What or where is this "ylabel" that you want to extract? Do you mean the tick labels on the y axis? And I don't know why you want to treat a plot of markers (diamonds?) as if it were an image. And I don't know what you are hoping to do with the "new" matrix.
Why don't we take a step back and start with the original x,y data you plotted. You say you have a "plot showing the area of connected components." I guess x is the blob number, and y is the area of the blob. Now, what do you want to do with that?