How do I redraw a picture given to me using its data points that I've found using the curve fitting app?
16 次查看(过去 30 天)
显示 更早的评论
Hello, I am trying to redraw this picture given to me by my professor. He told me to analyze it by curve fitting. So I did 4 fits and I was only able to get 3 fits into figures (SEM_data_points_figure, fit_poly2_figure, fit_poly3_fig) The last fit when I tried to save it as a figure kept giving me the error 'Index exceeds array bounds'. However, I need to redraw the picture using the data from these 3 fits. I need help please on how I can write code to go about doing this. Because the professor says I need to write code to get the data.
Thank you for the help.
The code below is from the data points from fit 4 which basically has the same data points as the 3 other fits. The data points for all 4 fits are basically the exact same points.
hold on;
%This is to make the D matrix
D=zeros(300,3);
%These are the data points from my fit poly 4 that I made into matrix form
%However, these cannot go into a matrix.
%How do I display these points in a figure?
D(0,0,0)=1;
D(100,0,0)=1;
D(140,0,0)=1;
D(160,0,0)=1;
D(180,0,0)=1;
D(201,0,0)=1;
D(215,0,0)=1;
D(230,0,0)=1;
D(260,0,0)=1;
imshow(D) %I know this can't work because its for a matrix
0 个评论
回答(2 个)
DGM
2025-6-30,0:21
I don't think anyone needs this answer now, but I came here from a related question that was more interesting, and got caught by how problematically simple this was.
% get the source image
hf = open('SEM_pic.fig');
hi = get(gca,'children');
inpict = hi.CData;
close(hf)
imshow(inpict)
% look at the data and fits
unzip SEM_data_points_figure.zip
hf = open('SEM_data_points_figure.fig'); % the "data"
hl = get(gca,'children');
Xd = hl.XData;
Yd = hl.YData;
Zd = hl.ZData;
close(hf)
unzip fit_poly2_figure.zip
hf = open('fit_poly2_figure.fig'); % fit2 is the same
hl = get(gca,'children');
X = hl.XData;
Y = hl.YData;
Z = hl.ZData;
close(hf)
[isequal(X,Xd) isequal(Y,Yd) isequal(Z,Zd)]
unzip fit_poly3_fig.zip
hf = open('fit_poly3_fig.fig'); % fit3 is the same
hl = get(gca,'children');
X = hl.XData;
Y = hl.YData;
Z = hl.ZData;
close(hf)
[isequal(X,Xd) isequal(Y,Yd) isequal(Z,Zd)]
The sem_data, fit_poly2, and fit_poly3 data are all exactly identical. The Y and Z data are purely zero. The X data contains 1799985 nonzero values, within which, there are only 8 unique values, all of which are integers apparently on uint8-scale.
The image was a 815x1630x3 PNG, the exact same number of elements as the data. This appears to be a vectorized copy of the original image, as almost all values are 0 or 255 (it's an antialiased pseudobinary image).
% just reshape the data to form the image??
outpict = reshape(uint8(X),[815 1630 3]);
imshow(outpict) % it looks the same
isequal(inpict,outpict) % it is the same
So I don't see any sort of curve fitting or anything going on here. I see an image and three identical vectorized copies of it, stored in different figure files for extra complication. I have no idea what was going on, but that's how you devectorize it, I guess? The fact that it's simple and the data is duplicated suggests to me that OP didn't know and probably wasted a lot of time thinking it was something else. Saved the wrong data? Been there.
This is the thread I'd found curious:
0 个评论
Image Analyst
2025-6-30,0:53
There may be other errors, but for one, you can't use 0 as the index into an array:
D(0,0,0)=1; % Will throw error.
Indexing starts at 1.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Smoothing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!