64,636
社区成员
发帖
与我相关
我的任务
分享
Mat src;
for (int col = 340; col < 350; col++) {
for (int row = 0; row < src.rows ; row++)
{
if (src.at<Vec3b>(col,row)[0] > 250
&& src.at<Vec3b>(col,row)[1] < 10
&& src.at<Vec3b>(col,row)[2] < 10)
cout << row << "," << col << endl;
}
}
Mat bw;
for (int y=0;y<bw.rows;y++) {
for (int x=0;x<bw.cols;x++) {
gray_value_at_y_x=bw.at<uchar>(y,x);
}
}
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
using namespace std;
using namespace Gdiplus;
int main() {
GdiplusStartupInput gdiplusstartupinput;
ULONG_PTR gdiplustoken;
GdiplusStartup(&gdiplustoken, &gdiplusstartupinput, NULL);
wstring infilename(L"1.jpg");
Bitmap* bmp = new Bitmap(infilename.c_str());
UINT height = bmp->GetHeight();
UINT width = bmp->GetWidth();
Color color;
for (UINT y = 0; y < height; y++)
for (UINT x = 0; x < width ; x++) {
bmp->GetPixel(x, y, &color);
if ((int)color.GetRed ()>200
&& (int)color.GetGreen()>200
&& (int)color.GetBlue ()>200) {
cout << x << "," << y << endl;
goto EXIT;
}
}
EXIT:
delete bmp;
GdiplusShutdown(gdiplustoken);
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
using namespace std;
using namespace Gdiplus;
int main() {
GdiplusStartupInput gdiplusstartupinput;
ULONG_PTR gdiplustoken;
GdiplusStartup(&gdiplustoken, &gdiplusstartupinput, NULL);
wstring infilename(L"1.jpg");
Bitmap* bmp = new Bitmap(infilename.c_str());
UINT height = bmp->GetHeight();
UINT width = bmp->GetWidth();
Color color;
for (UINT y = 0; y < height; y++)
for (UINT x = 0; x < width ; x++) {
bmp->GetPixel(x, y, &color);
if ((int)color.GetRed ()>200
&& (int)color.GetGreen()>200
&& (int)color.GetBlue ()>200) {
cout << x << "," << y << endl;
goto EXIT;
}
}
EXIT:
delete bmp;
GdiplusShutdown(gdiplustoken);
return 0;
}
[/quot
非常感谢您!