答案 0 :(得分:1)
你的意思是这样吗?
以下是我提出的代码(请注意,它取决于您必须从整个数据集中计算自己的阈值,这就是为什么它有点嘈杂):
clear all;
close all;
pkg load image
im=double(rgb2gray(imread("5JpXg.jpg")));
im=im(10:end-10,10:end-10);
%you can try to find a better threshold based on your data
threshold=100;
im(im<threshold)=0;%or im(im>threshold)=0 if you want everything to be blank except the circle and the rectangle
[m n]=size(im);
num_non_zero_pixels=size(im(im~=0),1);
x=zeros(3,num_non_zero_pixels);
counter=1;
for i=1:m
for j=1:n
if(0~=im(i,j))
x(1,counter)=i;
x(2,counter)=j;
x(3,counter)=im(i,j);
counter=counter+1;
end
end
end
plot3(x(1,:)',x(2,:)',x(3,:)',"*");