白色的地方是代表瑕疵點!! 請問要怎樣能標示出每個瑕疵的點!并能計算出個數呢?
可以給點簡單的code嗎? 初學者抱歉


uj5u.com熱心網友回復:
首先,我想你的真實影像應該沒有你做的這張圖這么清晰,所以最主要的是怎么識別出點,因為沒有實際的影像,沒法給你什么 演算法之類的東東但如果像你畫的這圖的話,就是很明顯的顏色取值判斷而已
至于標識位置,都知道了點的在哪有多大還不好標嗎
uj5u.com熱心網友回復:
如果真的那么清晰,把相連通的白色算一個,然后統計個數。完工。uj5u.com熱心網友回復:
如果真的像你圖片上這樣,只有黑白兩種顏色,而且每個圓圈又都是封閉的那處理就簡單了.首先找出一個白色像素的點,然后用ExtFloodFill 把這個圓圈填充成黑色就處理完這個了
接著像剛剛那樣處理下一個點,就可以了.
如果沒有這么理想的效果,那估計要用opencv等這些專門影像處理的庫來做了.
uj5u.com熱心網友回復:
抱歉 小弟不才 我目前可以分別找出沒相連的白點面積!! 但是我希望可以在每一個白點上標示出 1.2.3.4.5? 請問要怎么標是呢?下面是我目前的程式代碼

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
int count=0;
int Connect(Graphics::TBitmap * BMP, int x, int y)
{
count++;
BMP->Canvas->Pixels[x][y] = clBlack;
// ?? (x+1,y)
if(BMP->Canvas->Pixels[x + 1][y] == clWhite)
{
Connect(BMP, x + 1, y);
}
// ??(x + 1, y - 1)
if(BMP->Canvas->Pixels[x + 1][y - 1] == clWhite)
{
Connect(BMP, x + 1, y - 1);
}
// ?? (x+1,y+1)
if(BMP->Canvas->Pixels[x][y - 1] == clWhite)
{
Connect(BMP, x , y - 1);
}
// ?? (x,y-1)
if(BMP->Canvas->Pixels[x-1][y - 1] == clWhite)
{
Connect(BMP, x-1, y - 1);
}
// ?? (x,y-1)
if(BMP->Canvas->Pixels[x-1][y] == clWhite)
{
Connect(BMP, x-1, y);
}
// ?? (x-1,y)
if(BMP->Canvas->Pixels[x - 1][y+1] == clWhite)
{
Connect(BMP, x - 1, y+1);
}
// ?? (x-1,y-1)
if(BMP->Canvas->Pixels[x][y + 1] == clWhite)
{
Connect(BMP, x, y + 1);
}
// ?? (x+1,y)
if(BMP->Canvas->Pixels[x + 1][y+1] == clWhite)
{
Connect(BMP, x + 1, y+1);
}
// ?? (x-1,y+1)
if(BMP->Canvas->Pixels[x + 1][y] == clWhite)
{
Connect(BMP, x + 1, y);
}
return (count);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int j ;
int c = 0;
Graphics::TBitmap *BMP = new Graphics::TBitmap();
Byte *ptr=NULL;
BMP->Assign(Image1->Picture->Bitmap);;
for(int y = 0; y < BMP->Height; y++)
{
ptr = (Byte *) BMP->ScanLine[y];
for(int x = 0; x < BMP->Width; x++)
{
if(ptr[x*3]==255)
{
int cx= Connect(BMP, x, y);
Memo1->Lines->Add(cx);
count=0; //?0?
if (cx>=150 && cx<=500)
c+=1;
//break;
}
}
}
ShowMessage(c);
delete BMP;
}
//---------------------------------------------------------------------------
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/107131.html
標籤:基礎類
上一篇:fgets讀檔案讀不出來
下一篇:求Qt代理程式的示例
