導航:首頁 > 源碼編譯 > 種子點輪廓提取演算法

種子點輪廓提取演算法

發布時間:2022-07-10 23:23:29

❶ 你好,怎麼提取種子的特徵數據啊,有好的方法嗎

提取種子的特徵數據時種子顆粒飽滿、充實,其內營養物質就相對的較多,相應的發芽率高,發芽整齊,植株生命力旺盛。

而種子的大小、顆粒飽滿程度用以下方法來鑒定:

我們可以用千粒重來判定一類種子的大小即飽滿程度是一種很簡便的方法。而千粒重的測定需要藉助種子數粒儀和一定精度的天平。

種子千粒重是指在一定的環境條件下1000粒種子的重量。

其測定方法為從樣品種子中扦樣抽取1000粒種子,在扦樣前先對種子進行凈度分析,然後稱重,重復兩次以上,再求其平均值,得到的參數就是千粒重。此間,1000粒種子需要電子自動數粒儀來進行數粒。

這里需要注意幾點:大、中粒子對天平的要求為感量在0.1g,而10g以下的種子對天平的要求更高些,感量需在0.01g.試樣質量≤1g,稱至4位小數;1-9.99g的稱重至3位小數;10-999.9g的稱重至2位小數;1000g以上稱重至整數。如果前後兩次測量差值不超過5%,則可停止稱重,將其兩份試樣的重量平均,得到種子的千粒重。如果超過允許誤差,則需再次進行數粒、稱重,直到兩次稱重在允許誤差之內,然後再計算得出種子的千粒重。

❷ 輪廓提取的演算法有哪些

LZ你問的問題太寬泛了,不同對象有不同的處理方法。
可以參考一下廣義Hough變換、Haar及Canny這些,看看對你的研究有沒有幫助。

❸ 自動提取像點坐標的演算法

不知道你學的什麼.我是學C++的.按照編程的思路來說,一般遇到這樣的問題,我們都會逐像素橫向check,第一次遇到白點後記錄,然後繼續,橫向遇到黑點停止,然後計算兩點間的像素,得到直徑,就可以得到中點了,然後繼續再橫向check直到整個圖完結,希望能幫到你

❹ 提取圖像輪廓的問題

matlab自帶的那幾個邊界提取函數好像都只能提取出原圖像的邊界,我幫你改了一下,你把bw=bwperim(f);(包括這句)以後的代碼都去掉,用我給你寫的這個,就可以提取出圖像上下左右邊界的坐標了。你可以輸出一下看看是否正確
[x,y]=size(f);
for i=1:x
f(i,2)=0;
f(i,y-1)=0;
end
for j=1:y
f(2,j)=0;
f(x-1,j)=0;
end
[m1,n1]=find(f);
maxx=max(m1); %%最大x值
maxy=max(n1); %%最大y值
minx=min(m1); %%最小x值
miny=min(n1); %%最小y值

希望對你能有所幫助。

❺ 請問哪位高手幫忙解答:邊緣檢測和輪廓提取是一回事嗎如果不是,請問區別在哪呢謝謝,急求答案

不一樣的。輪廓提取主要是從一個種子點,用搜索的方法找到閉合的輪廓。邊緣檢測主要是根據圖像上的邊緣在像素上變化很大的,用微分的方法,找到邊緣。一般邊緣檢測後都要做二值化處理,把邊緣和背景分割出來。輪廓就不用二值化,因為搜索的時候已經將得到的輪廓存起來了~

❻ 請教基於opencv的輪廓提取問題

先灰度化->二值化,弄成二值圖,你就會提取了

給你個例子
C/C++ code

#include <stdio.h>

#include "cv.h"

#include "cxcore.h"

#include "highgui.h"

#include <iostream>

using namespace std;

#pragma comment(lib,"cv.lib")

#pragma comment(lib,"cxcore.lib")

#pragma comment(lib,"highgui.lib")

struct Position

{

int x,y;

};

double per[256];// 保存灰度概率

IplImage *FindCountours(IplImage* src,IplImage *pContourImg);

int ImageStretchByHistogram(IplImage *src,IplImage *dst);

IplImage* Hist_Equalization(IplImage *srcimg);

void proBorder(IplImage *src); // 邊界的處理

void GetBackImage(IplImage* src,IplImage* src_back);

void Threshold(IplImage *src);

int GetThreshold(double *const prob);

void Getprobability(IplImage *src);

double Eccentricity(IplImage *src);

void main()

{

//IplImage * src = cvLoadImage("C:\\image19\\A634.jpg",-1);//灰度圖的方式載入

IplImage * src = cvLoadImage("C:\\image19\\A857.jpg",-1);

IplImage * dst = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,3);

IplImage *src_back = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,src->nChannels);

GetBackImage(src,src_back);

dst = FindCountours(src_back,dst);

cvNamedWindow("test",CV_WINDOW_AUTOSIZE);

cvShowImage("test",dst);

cvWaitKey(0);

cvReleaseImage(&src);

cvReleaseImage(&dst);

}

void GetBackImage(IplImage* src,IplImage* src_back)

{

//cvCvtColor(src,src,CV_RGB2GRAY);//灰度化

IplImage *tmp = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,3);

// 創建結構元素

IplConvKernel *element = cvCreateStructuringElementEx( 2, 2, 0, 0, CV_SHAPE_ELLIPSE,0);

//用該結構對源圖象進行數學形態學的開操作後,估計背景亮度

cvErode(src,tmp,element,9);

//使用任意結構元素腐蝕圖像

cvDilate(tmp,src_back, element,9);

//使用任意結構元素膨脹圖像

}

IplImage *FindCountours(IplImage* src,IplImage *pContourImg)

{

CvMemStorage *storage = cvCreateMemStorage(0); //提取輪廓需要的儲存容量為默認KB

CvSeq * pcontour = 0; //提取輪廓的序列指針

IplImage *temp = cvCreateImage(cvGetSize(src),src->depth,1);

//cvSmooth(src,temp,CV_GAUSSIAN,3,1,0);

cvSmooth(src,src,CV_GAUSSIAN,3,1,0);//平滑處理

cvCvtColor(src,temp,CV_RGB2GRAY);//灰度化

Getprobability(temp);

printf("最好的閾值:%d\n",GetThreshold(per));

//Threshold(temp);

proBorder(temp);

cvThreshold(temp,temp,GetThreshold(per),255,CV_THRESH_BINARY_INV);

int contoursNum = 0; // 輪廓數量

//int mode = CV_RETR_LIST;

int mode = CV_RETR_EXTERNAL;// 提取最外層輪廓

contoursNum = cvFindContours(temp,storage,&pcontour,sizeof(CvContour),mode,CV_CHAIN_APPROX_NONE);

// contoursNum = cvFindContours(temp,storage,&pcontour,sizeof(CvContour),CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE,cvPoint(0,0));

//二值圖, 得到輪廓存儲,輪廓指針序列,header_size,提取模式,逼近方法

CvScalar externalColor;// 保存顏色值

CvScalar holeColor;

//————–畫輪廓—————-//

for (; pcontour != 0; pcontour=pcontour -> h_next)

{

//holeColor=CV_RGB(rand()&255,rand()&255,rand()&255);

//externalColor=CV_RGB(rand()&255,rand()&255,rand()&255);

CvRect r = ((CvContour *)pcontour)->rect;

if(r.height * r.width < 800)

{

holeColor=CV_RGB(0,0,0);

externalColor=CV_RGB(0,0,0);

cvDrawContours(pContourImg,pcontour,externalColor,holeColor,1,1,8);

}

else

{

//取得輪廓面積

double contArea = fabs(cvContourArea(pcontour,CV_WHOLE_SEQ));

//取得輪廓長度

double contLenth = cvArcLength(pcontour,CV_WHOLE_SEQ,-1);

// 圓形度

double contcircularity = contLenth * contLenth / contArea;

double pxl =Eccentricity(temp);

cout<<"面積為:"<<contArea<<endl;

cout<<"周長為:"<<contLenth<<endl;

cout<<"圓形度為:"<<contcircularity<<endl;

holeColor=CV_RGB(255,255,255);

externalColor=CV_RGB(255,255,255);

cvDrawContours(pContourImg,pcontour,externalColor,holeColor,1,1,8);

}

}

//IplConvKernel *element = cvCreateStructuringElementEx( 2, 2, 0, 0, CV_SHAPE_ELLIPSE,0);

//cvDilate(pContourImg,pContourImg, element,9);

return pContourImg;

}

double Eccentricity(IplImage *src)//偏心率

{

Position pos[4];

int width = src->width;

int height = src->height;

int i,j;

for(i = 0; i < height; i++)

{

for(j = 0; j < width; j++)

{

int pixel = (int)cvGet2D(src,i,j).val[0];

if(pixel != 0)

{

pos[0].x = j;

pos[0].y = i;//

goto s;

}

}

}

s:

for(i = height – 1; i >= 0; i–)

{

for(j = 0; j < width ; j++)

{

int pixel = (int)cvGet2D(src,i,j).val[0];

if(pixel != 0)

{

pos[1].x = j;

pos[1].y = i;//

goto w;

}

}

}

w:

for(i = 0 ; i < width ; i++)

{

for(j = 0;j < height; j++)

{

int pixel = (int)cvGet2D(src,j,i).val[0];

if(pixel != 0)

{

pos[2].x = j;//

pos[2].y = i;

goto e;

}

}

}

e:

for(i = width – 1; i >= 0; i–)

{

for(j = 0 ; j < height ; j++)

{

int pixel = (int)cvGet2D(src,j,i).val[0];

if(pixel != 0)

{

pos[3].x = j;//

pos[3].y = i;

goto f;

}

}

}

f:

int l_dis = abs(pos[0].y – pos[1].y);

int s_dis = abs(pos[2].x – pos[3].x);

int tmp_dis;

if(l_dis > s_dis)

{

printf("偏心率:%f\n",l_dis*1.0/s_dis);

}

else

{

tmp_dis = l_dis;

l_dis = s_dis;

s_dis = tmp_dis;

printf("偏心率:%f\n",l_dis*1.0/s_dis);

}

return 0;

}

void Getprobability(IplImage *src)

{

memset(per,0,sizeof(per));

int width = src->width;

int height = src->height;

for(int i = 0; i < height; i++) {

for(int j = 0; j < width; j++) {

per[(int)cvGet2D(src,i,j).val[0]]++;

}

}

int PixlNum = width * height;

for(i = 0; i < 256; i++)

per[i] = per[i] / PixlNum;

}

int GetThreshold(double *const prob)

{

int threshold = 0;

double maxf = 0;

for (int crrctThrshld = 1; crrctThrshld < 256 – 1; ++crrctThrshld) {

double W0 = 0, W1 = 0, U0 = 0, U1 = 0;

int i = 0;

for (i = 0; i <= crrctThrshld; ++i) {

U0 += i * prob[i];

W0 += prob[i];

}

for (; i < 256; ++i) {

U1 += i * prob[i];

W1 += prob[i];

}

if (W1 == 0 || W1 == 0)

continue;

U0 /= W0;

U1 /= W1;

double D0 = 0, D1= 0;

for (i = 0; i <= crrctThrshld; ++i)

D0 += pow((i – U0) * prob[i], 2.0);

for (; i < 256; ++i)

D1 += pow((i – U1) * prob[i], 2.0);

D0 /= W0;

D1 /= W1;

double Dw = pow(D0, 2.0) * W0 + pow(D1, 2.0) * W1;

double Db = W0 * W1 * pow((U1 – U0), 2.0);

double f = Db / (Db + Dw);

if (maxf < f) {

maxf = f;

threshold = crrctThrshld;

}

}

return threshold;

}

void proBorder(IplImage *src) // 邊界的處理

{

int i,j;

int height = src->height;

int width = src->width;

int N = 100;

for(i = 0; i < N * width; i += width) // i表示向下走左上角

{

for(j = 0; j < N ; j++)

{

int index = i + j;

src->imageData[index] = (char)255;

}

}

int NN = 150;

int sw = width * (height – NN);// 左下角 三角形

int t = 1;

for(i = sw; i < sw + NN * width; i += width,t++)

{

for(j = 0; j < t; j++)

{

int index = i + j;

src->imageData[index] = (char)255;

}

}

int se = (height – NN – 1) * width; // 右下角

t = 0;

for(i = se; i < width * height ; i += width,t++)

{

for(j = 0; j < t; j++)

{

int index = i + j – t;

src->imageData[index] = (char)255;

}

}

int ne = width – NN; // 右上角 三角形剪切

t = 0;

for(i = ne; i < NN * width; i +=width,t++)

{

for(j = 0; j < NN – t; j++)

{

int index = i + j + t;

src->imageData[index] = (char)255;

}

}

}

void Threshold(IplImage *src)

{

int width = src->width;

int height = src->height;

float minpixel = cvGet2D(src,0,0).val[0];

float maxpixel = cvGet2D(src,0,0).val[0];

CvScalar s;

for(int i = 0; i < height; i++){

for(int j = 0; j < width; j++){

s = cvGet2D(src,i,j);

if(s.val[0] > maxpixel)

maxpixel = s.val[0];

if(s.val[0] < minpixel)

minpixel = s.val[0];

}

}

float firstgrey = (maxpixel + minpixel) / 2;

printf("%f\n",firstgrey);

float lastgrey;

float sum1 = 0,sum2 = 0;

int num1 = 0,num2 = 0;

int result = 0;

❼ 如何提取輪廓上每個點的坐標

mode = CV_RETR_LIST;
contours_num=cvFindContours(preimg, storage, &contours, sizeof(CvContour), mode, CV_CHAIN_APPROX_NONE, cvPoint(0,0));
for (;contours!=0;contours=contours->h_next)
{
onetourlength = contour->total;
CvPoint *points = (CvPoint *)malloc(sizeof(CvPoint) * onetourlength);
//printf("seqlength:%dn",seqlength);
CvSeqReader reader;
CvPoint pt = cvPoint(0,0);
cvStartReadSeq(contour,&reader);
for(int i = 0 ;i < onetourlength; i++){
CV_READ_SEQ_ELEM(pt,reader);
points[i] = pt;
cvSeqPush(allpointsSeq,&pt);
}
cvPolyLine(image,&points,&onetourlength,1,0,CV_RGB(0,255,0),2,8,0);
}

閱讀全文

與種子點輪廓提取演算法相關的資料

熱點內容
噴油螺桿製冷壓縮機 瀏覽:578
python員工信息登記表 瀏覽:376
高中美術pdf 瀏覽:160
java實現排列 瀏覽:512
javavector的用法 瀏覽:981
osi實現加密的三層 瀏覽:231
大眾寶來原廠中控如何安裝app 瀏覽:915
linux內核根文件系統 瀏覽:242
3d的命令面板不見了 瀏覽:525
武漢理工大學伺服器ip地址 瀏覽:148
亞馬遜雲伺服器登錄 瀏覽:524
安卓手機如何進行文件處理 瀏覽:70
mysql執行系統命令 瀏覽:929
php支持curlhttps 瀏覽:142
新預演算法責任 瀏覽:443
伺服器如何處理5萬人同時在線 瀏覽:250
哈夫曼編碼數據壓縮 瀏覽:425
鎖定伺服器是什麼意思 瀏覽:383
場景檢測演算法 瀏覽:616
解壓手機軟體觸屏 瀏覽:349