给定尺寸为 26 * 7 的图像是否有可能在垫子的每一行中包含 78 个单独的颜色值,而另一个可以包含 77
Is it possible that an image of a given size of 26 * 7 can contain 78 separate colour values in each row of the Mat ,and another can contain 77?
给定
大小为 26 * 7 的图像是否可以在 Mat 的每一行中包含 78,77 或 79 个值?为什么会这样?我有 95 张图像,都是 26 x 7,我发现有些图像每行有 77 个单独的颜色值,有些有 79.这是有问题的,因为我需要一个标准值。
这就是将图像裁剪为 26 x 7 大小的方式。
Mat standard_size=largestObject1(Rect(0,0,26,7));//a template to get the standard _size of a binary image
cv::resize(thresholdi,thresholdi,standard_size.size());
如果我只能将其转换为 26 像素值,我会丢失信息吗?
I create the following code:-
ofstream in("Eye_Gestures.txt");
//Eye Graze Class
IplImage *img2 = cvLoadImage("eye2.bmp");
Mat imgg2=cvarrToMat(img2);
Formatted line0i2 = format(imgg2.row(0),"CSV" );
Formatted line1i2 = format(imgg2.row(1),"CSV" );
Formatted line2i2 = format(imgg2.row(2),"CSV" );
Formatted line3i2 = format(imgg2.row(3),"CSV" );
Formatted line4i2 = format(imgg2.row(4),"CSV" );
Formatted line5i2 = format(imgg2.row(5),"CSV" );
Formatted line6i2 = format(imgg2.row(6),"CSV" );
in<<line0i2<<", "<<line1i2<<", "<<line2i2<<", "<<line3i2<<", "<<line4i2<<", "<<line5i2<<", "<<line6i2<<", "<<EyeGraze<<endl;
我需要确保每行为所有 95 张图像存储相同数量的单独颜色值。如果它是 77 个值,则每个图像的所有行都需要为 77。如何确保将 77 而不是 78 或 79 个值传递给文本文件?如何忽略每行的多余值?如何跟踪行上的单独颜色值而不必手动计数它们?
26 x 7 像素的图像包含 7 行,每行 26 像素。一行不会有 27 个像素,更不用说 77 个像素了。你完全糊涂了。
回过头来重新思考你真正想要实现的目标。请注意,文本文件不是图像文件的自然格式。
位图 (bmp) 图像每个像素正好包含 1 个条目。根据您使用的位图类型,这些位图的分辨率可能不同(但始终恒定)。
您用于将 bmp 转换为 csv 文本表示的方法似乎将每个像素序列化为一组 3 个值(可能是 rgb)。如果在宽度为 26px 的图像中,每行获得的条目数与 78 个不同,则很可能在读取文件时犯了一些错误。
常见的错误是表示为空单元格","的 0 值,或者 - 取决于您使用的区域设置 - 十进制逗号字符和 csv 分隔符之间的混淆。
您确定分隔符确实是您在写入输出流时用于分隔行','
字符,该输出流被混淆地命名为 in
?
相关文章:
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 编译包含字符串的代码时遇到问题
- c++库的公共头文件中应该包含什么
- 用c++从输入文件中读取另一行
- 读取文件的最后一行并输入到链接列表时出错
- 将包含C样式数组的对象初始化为成员变量(C++)
- 是否需要删除包含对象的"pair"?
- 我正在使用嵌套的while循环来解析具有多行的文本文件,但由于某种原因,它只通过第一行,我不知道为什么
- 从C++dll访问C#中的一行主要参数
- 如何在Visual Studio 2013 Ultimate Edition中包含某个单词的每一行中插入断点
- 我需要在一行中包含所有具有相同关键字的值
- 给定尺寸为 26 * 7 的图像是否有可能在垫子的每一行中包含 78 个单独的颜色值,而另一个可以包含 77
- 如何在C++中找到一行中包含反斜杠字符的字符串
- 如果一行包含某个单词,请保存它
- 文件IO -删除一行包含特定字符串的文本
- 确定文件中的一行是否包含阿拉伯数字或罗马数字的c++程序
- 如何从包含多行的文本文件中只读取一行
- 当一行只包含制表符时,处理制表符描绘的文本文件
- 如何将一行作为输入而不包含空格