例如,您可以尝试通过三种不同的方法来隔离对象。
让我们在 Mathematica 中执行此操作。 (MATLAB 是your家庭作业)。
我们来调用我们的图像i:
i =
让我们尝试隔离一个名为mask:
mask =
请参阅示例代码:
(* First Method, by Image Correlation*)
x = ImageCorrelate[ i, mask, EuclideanDistance];
r = Position[ImageData@Binarize[x, 0.2], 0, Infinity];
(*Show that we found the right spot *)
ImageCompose[i,
ColorNegate@
mask, {0, Dimensions[ImageData[i]][[1]]} - {-1, 1} Reverse[r[[1]]]]
结果:
(* Second method, separating channels,
thresholding and deleting small components*)
r = DeleteSmallComponents@Binarize[#, .99] &@
ColorNegate[ColorSeparate[i][[3]]];
ImageMultiply[i, r]
结果:
(* Third method, extracting the exact color *)
Image[ImageData[i] /. {1., 0.6, 0.} -> {a} /. {_, _, _} -> {0, 0,0} /.
{a} -> {1., 0.6, 0.}]
结果:
HTH!