简体   繁体   English

如何从图像和识别位置中删除特定颜色?

[英]How can i remove specific color from Image and Identify Positions?

I have an image as .png , i want to do following tasks with given image : 我的图像为.png,我想用给定的图像执行以下任务:

1 - Remove unnecessary White shade from image. 1 -从图像中删除不必要的白色阴影。

2 - Identify positions/coordinates of big black point in image. 2 -识别图像中大黑点的位置/坐标。

For Task 1 my attempt is: 对于Task 1我的尝试是:

img = imread('1.png');
imshow(img);
I = img;
[r c] = size(I);
for i=1:r
    for j=1:c
        if I(i,j) > 230 %here i am changing 240 to different values to get result 
            %but this is just some hack
            I(i,j) = 0;
        end
    end
end
imshow(I);

Where Original Image is : 原始图像在哪里:

duck_unprocess

And Matlab results are : 而Matlab的结果是:

duck_process And for (2) i am out of ideas how can i do that any help appreciated. 对于(2)我没有想法我怎么能做到这一点任何帮助赞赏。

Note: I am new in image processing, so kindly explain me in easy way so i can understand. 注意:我是图像处理的新手,所以请以简单的方式向我解释,以便我能理解。 thanks 谢谢

For task 1, I am not entirely sure what you mean by "removing", from your code, I guess you would like to set the pixel values to 0. A simpler and faster method would be: 对于任务1,我不完全确定你的代码中“删除”是什么意思,我想你想将像素值设置为0.一个更简单,更快的方法是:

img = imread('1.png');
img(img>230)=0;

This code sets all the values of img that are higher than 230 to zero. 此代码将img的所有高于230的值设置为零。 img>230 creates a logical array with the size of img, true for elementes higher than 230, and false for others. img> 230创建一个大小为img的逻辑数组,对于高于230的元素为true,对于其他元素为false。 Then this logical array is used to set those pixels to 0. (But you could do anything you want with them) 然后这个逻辑数组用于将这些像素设置为0.(但你可以用它们做任何你想做的事)

Matlab was designed to do operations on vectors and matrices, looping through the elements is usually much slower. Matlab设计用于对向量和矩阵进行操作,循环遍历元素通常要慢得多。

For task 2, maybe look into this: http://nl.mathworks.com/help/images/examples/detect-and-measure-circular-objects-in-an-image.html 对于任务2,可以看看这个: http//nl.mathworks.com/help/images/examples/detect-and-measure-circular-objects-in-an-image.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM