在matlab中找出离散或连续的图像

时间:2014-03-07 19:30:16

标签: matlab image-processing pattern-matching computer-vision

我有两张照片。一个是连续的,另一个是离散的。我想自动确定哪一个是离散的(标志:1),哪一个是连续的(标志:0)。我的两个图像都在matlab和2D(不是rgb)中。

enter image description here

1 个答案:

答案 0 :(得分:2)

遵循@ chappjc的好主意:连续图像是具有更多颜色的图像,另一个是离散图像。

img1 = rand(100,200,3); %// example continuous image
img2 = randi(5,100,200,3)/10; %// example discrete image

[m1 n1 p1] = size(img1);
c1 = size(unique(reshape(img1, m1*n1, p1), 'rows'),1); %// number of colors
[m2 n2 p2] = size(img2);
c2 = size(unique(reshape(img2, m2*n2, p2), 'rows'),1); %// number of colors

if c1>c2
    disp('First image is continuous, second is discrete')
else
    disp('First image is discrete, second is continuous')
end