真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

圖像處理并獲取RGB-創(chuàng)新互聯(lián)

截取自霧霾檢測機

創(chuàng)新互聯(lián)建站主要從事成都網(wǎng)站制作、做網(wǎng)站、網(wǎng)頁設計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務。立足成都服務宜黃,十載網(wǎng)站建設經(jīng)驗,價格優(yōu)惠、服務專業(yè),歡迎來電咨詢建站服務:18980820575

-(float) returnGrayVale:(UInt8*)buffer withBytesPerRow:(size_t)bytesPerRow withX:(int)x withY:(int)y{

    UInt8*  tmp;

    tmp = buffer + y * bytesPerRow + x * 4; // RGBAの4つ値をもっているので、1ピクセルごとに*4してずらす

    // 獲取圖像的RGB

    UInt8 red,green,blue;

    red = *(tmp + 0);

    green = *(tmp + 1);

    blue = *(tmp + 2);

    //獲取灰度值

    float grayValue = [self returnGrayValueWithRGB:red withGreen:green withBlue:blue];

    return grayValue;

}

-(float)ClearIndexBySobel:(UIImage*)sourceImage fromX:(int)Xpoint fromY:(int)Ypoint zoneWidth:(int)Width zoneHeihgt:(int)Height{

    int p_w_picpathWidth = sourceImage.size.width;

    int p_w_picpathHeight = sourceImage.size.height;

    //防止越界處理

    if (Xpoint<=0 || Xpoint>=p_w_picpathWidth-1 || Ypoint<=0 || Ypoint>=p_w_picpathHeight-1) {

        return -1;

    }

    //獲取ref對象

    CGImageRef  p_w_picpathRef;

    p_w_picpathRef = sourceImage.CGImage;

    // 一行有多少個字節(jié)

    size_t                  bytesPerRow;

    bytesPerRow = CGImageGetBytesPerRow(p_w_picpathRef);

    CGDataProviderRef   dataProvider;

    dataProvider = CGImageGetDataProvider(p_w_picpathRef);

    CFDataRef   data;

    UInt8*      buffer;

    data = CGDataProviderCopyData(dataProvider);

    buffer = (UInt8*)CFDataGetBytePtr(data);

    //循環(huán)計算區(qū)域像素點獲得總的梯度值

    float sum_grad = 0;

    int count = 0;

    for (int y = Ypoint; y < Ypoint + Height; y++) {

        for (int x = Xpoint; x < Xpoint + Width; x++) {

            //計算周邊8個點的灰度值

            float gray_00 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x-1 withY:y-1];

            float gray_01 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x-1 withY:y];

            float gray_02 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x-1 withY:y+1];

            float gray_10 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x withY:y-1];

            float gray_12 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x withY:y+1];

            float gray_20 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x+1 withY:y-1];

            float gray_21 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x+1 withY:y];

            float gray_22 = [self returnGrayVale:buffer withBytesPerRow:bytesPerRow withX:x+1 withY:y+1];

            //計算梯度值

            float grad_x = gray_00-gray_02+2*gray_10-2*gray_12+gray_20-gray_22;

            float grad_y = gray_00+2*gray_01+gray_02-gray_20-2*gray_21-gray_22;

            float grad=sqrt(grad_x*grad_x+grad_y*grad_y);

            sum_grad +=grad;

            count++;

        }

    }

    if(count<=0){

        return 0;

    }

    float clearIndex = sum_grad / count;

    dataProvider = nil;

    data = nil;

    buffer = nil;

    return clearIndex;

}

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。


當前題目:圖像處理并獲取RGB-創(chuàng)新互聯(lián)
鏈接URL:http://weahome.cn/article/poghe.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部