【VC+映像】圖片批量處理

來源:互聯網
上載者:User

-------------------------------------------------------------------------------------------------------------------------------

圖片批量處理

SkySeraph July 4th 2011  HQU

Email:zgzhaobo@gmail.com    QQ:452728574

Latest Modified Date:July 4th 2011 HQU

-------------------------------------------------------------------------------------------------------------------------------

批量處理檔案夾下所有的圖片,以彩色映像灰階化為例,直接添代碼:

int main(int argc,char** argv){WIN32_FIND_DATAA FileData;   HANDLE hFind;              hFind = FindFirstFileA((LPCSTR)"Imgs/*.jpg",&FileData);       if (hFind == INVALID_HANDLE_VALUE){           printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError ());           return 0;       }  while (FindNextFileA(hFind, &FileData)){           cout<<FileData.cFileName<<endl;           string name("Imgs/");           name.append(FileData.cFileName);           IplImage* src=cvLoadImage(name.c_str());           if (!src) {               cout<<"failed to load image"<<endl;  //API//AfxMessageBox("failed to load image"); //MFC            break;           }   assert(src->nChannels==3);  // 處理IplImage* srcGray = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,1);cvCvtColor(src,srcGray,CV_BGR2GRAY);// 儲存name.append(".srcGray.jpg"); cvSaveImage(name.c_str(),srcGray); cvReleaseImage(&src);           cvReleaseImage(&srcGray);   }         FindClose(&hFind);  return 0;}

  

效果(省)

 

-------------------------------------------------------------------------------------------------------------------------------

對比參考:

如何批量處理一個檔案夾的圖片檔案 http://www.opencv.org.cn/forum/viewtopic.php?t=12510

遍曆讀取指定檔案夾下指定類型的所有檔案 http://blog.csdn.net/carson2005/archive/2011/03/31/6292726.aspx

http://hi.baidu.com/yibobin/blog/item/c43e6801c7a10e111c95830d.html  圖片批量歸一化處理

http://www.doc88.com/p-91973419874.html  如何用VC++實現檔案的批量處理

http://hi.baidu.com/%B9%C2%D6%DB%B5%F6%BF%CD/blog/item/d69f91c5e1f0ed029d163dc8.html 

opencv 圖片實現格式轉換,並使用批處理實現批量轉換

-------------------------------------------------------------------------------------------------------------------------------

Author:         SKySeraph

Email/GTalk: zgzhaobo@gmail.com    QQ:452728574

From:         http://www.cnblogs.com/skyseraph/

本文著作權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文串連,否則保留追究法律責任的權利.

 -------------------------------------------------------------------------------------------------------------------------------

 

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.