【发布时间】:2015-11-11 01:58:58
【问题描述】:
我已经从 2D 图像构建了 3D 模型。我想知道我的模型使用一些统计测试的准确度如何。我认为有很多可用的方法可以做到这一点,比如这个问题Is it possible to compare 3D images? 中提到的相关性和均方。
我在其他网站上找不到可用测试的清晰描述。我在这里找到了一个使用正方形方法比较 2D 图像的实现,http://www.mathworks.com/matlabcentral/answers/81048-mse-mean-square-error。我不确定这是否可以用来计算模型精度。另外,我没有找到关于测试如何工作的解释,即比较了哪些参数(颜色、强度等)?
编辑:为了更清晰,3D 模型将 2D 图像中的每个像素表示为一个体素,它具有与之相关的颜色。该模型的目的是将 2D 图像中发现的不同颜色区域重建为 3D 表示。因此,具有某种颜色的像素(它们代表一个区域)的数量是从 2D 图像中计算出来的。将在 3D 模型中构建相似数量的体素并赋予相同的颜色。在这个建模问题中重要的是以下内容,
1- 区域大小(在 2D 图像和模型中必须几乎相似)。
2-2D图像中某个区域的连通性水平与其在3D图像中构造的对应区域必须相似。通过连接性,我的意思是检查区域组件是否分散在图像中,或者它们是否连接形成一个大的连接区域,而不是许多相同颜色的小分散区域。
EDIT2:我认为颜色相关图是合适的。我找到了实现它的代码,但我不清楚。这是代码,
% Soumyabrata Dev
% E-mail: soumyabr001@e.ntu.edu.sg
% http://www3.ntu.edu.sg/home2012/soumyabr001/
I= imread ('img.jpg');
correlogram_vector=[];
[Y,X]=size(rgb2gray(I));
% quantize image into 64 colors = 4x4x4, in RGB space
[img_no_dither, ~] = rgb2ind(I, 64, 'nodither');
% figure, imshow(img_no_dither, map);
%rgb = ind2rgb(img_no_dither, map); % rgb = double(rgb)
distance_vector= [1 3];
[~,d]=size(distance_vector);
count_matrix=zeros(64,d); total_matrix=zeros(64,d);
prob_dist=cell(1,d);
for serial_no=1:1:d
for x=1:X
for y=1:Y
color=img_no_dither(y,x);
% At the given distance
[positive_count,total_count]=get_n(distance_vector(serial_no),x,y,color,img_no_dither,X,Y);
count_matrix(color+1,serial_no)=count_matrix(color+1,serial_no)+positive_count;
total_matrix(color+1,serial_no)=total_matrix(color+1,serial_no)+total_count;
end
end
prob_dist{serial_no}=count_matrix(:,serial_no)./(1+total_matrix(:,serial_no));
end
for serial_no=1:d
correlogram_vector=cat(1,correlogram_vector,prob_dist{serial_no});
end
end
这是get_n方法,
function [positive_count,total_count]=get_n(n,x,y,color,img_no_dither,X,Y)
% This function is useful to get the validity map of the neighborhood case.
% It can handle any number of neighborhood distances.
% Input
% n=The order of the neighborhood
% x & y= x y co-ordinates of the given pixel
% color= particular quantized color
% img_no_dither= The color quantized image matrix
% X & Y= The original dimensions of the input image
% Output
% positive_count= The number of occurences which have the same color
% total_count= The total number of valid cases for this particular instant
valid_vector8n=zeros(1,8*n); % This is because of the propoerty of inf-norm. Each distance has 8 times the order
positive_count=0; total_count=0;
nbrs_x=zeros(1,8*n); nbrs_y=zeros(1,8*n);
% The counting of the pixels is done in the following manner: From the
% given pixel, go left-->up-->right-->down-->left-->up
% Y co-ordinates of nbrs
nbrs_y(1)=y;
d=1;
for k=2:1+n
nbrs_y(k)=y-d;
d=d+1;
end
nbrs_y(1+n:1:3*n+1)=y-n;
d=0;
for k=3*n+1:5*n+1
nbrs_y(k)=y-n+d;
d=d+1;
end
nbrs_y(5*n+1:1:7*n+1)=y+n;
d=0;
for k=7*n+1:1:7*n+1+(n-1)
nbrs_y(k)=y+n-d;
d=d+1;
end
% X co-ordinates of nbrs
nbrs_x(1)=x-n;
nbrs_x(2:1:1+n)=x-n;
d=0;
for k=1+n:1:3*n+1
nbrs_x(k)=x-n+d;
d=d+1;
end
nbrs_x(3*n+1:5*n+1)=x+n;
d=0;
for k=5*n+1:7*n+1
nbrs_x(k)=x+n-d;
d=d+1;
end
nbrs_x(7*n+1:7*n+1+(n-1))=x-n;
% Assigning the validity of the neighborhood
for i=1:8*n
if nbrs_x(i)>0 && nbrs_x(i)<=X && nbrs_y(i)>0 && nbrs_y(i)<=Y
valid_vector8n(i)=1;
else
valid_vector8n(i)=0;
end
end
% Couting the number of common colors in the valid areas of the
% neighborhood.
for j=1:8*n
if valid_vector8n(j)==1
data= img_no_dither(nbrs_y(j),nbrs_x(j));
if (data==color)
positive_count=positive_count+1;
end
total_count=total_count+1;
end
end
end
谁能解释一下这段代码是如何工作的?
上面的代码是针对 autocorrelogram 而不是 correlogram。我读过第一个更好,但它只能使用相同颜色的像素计算空间概率(不能应用于具有不同颜色的像素对)。这是正确的吗?
谢谢。
【问题讨论】:
-
我建议不要要求提供包含多个答案的详细列表,而是尝试将问题集中在模型的目的上(是否用于(重新)可视化艺术品、测量、机器人导航?) ,并给出你的基本事实数据的性质。一个小的 matlab 代码来帮助解释,可以让事情保持在主题上。为了使准确度指标有用,它需要能够计算它,加上它需要与您尝试解决的原始问题相关。
-
@NeilSlater 我编辑了这个问题。请看一下。谢谢。
-
不幸的是,这仍然过于宽泛。我建议您查看您所在领域的文献,了解常用的方法类型,然后根据该信息和您对数据的了解选择适当的指标。
-
您似乎想将从 3d 模型重建的一些指标与直接从底层 2d 图像中提取的指标进行比较。到目前为止,一切都很好。但是,我看不到任何方法可以在这里进行统计测试,因为您只有一个实例。对于任何类型的测试,您都需要一个样本,例如图像样本和相应的 3d 模型。另外,要检验的原假设是什么?
-
很抱歉,我也没有看到这发生在三个不同的剪辑中。通常不同的样本值需要在统计上独立。您可以在 stats.SE 上试试运气(标记您的问题并让版主将其移到那里),但我并不乐观。
标签: matlab image-processing 3d statistics modeling