Opencv库,获取没有标题的数据? [英] Opencv library , get data without header ?

查看:97
本文介绍了Opencv库,获取没有标题的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿朋友

我开始使用c编程开始使用opencv

- 首先,我将图像格式greyscale pgm转换为二进制缺乏和白色

-i想要只获取没有标题的图像数据?没有改变图像的属性

-if opencv有一个功能,这是好的;

但如果它没有这样我认为使用2缓冲区一个头我将每个文件保存为一个文件(文件来自标题,一个文件来自数据)后,数据为2,这是探测器,但这里的探测器是我如何返回初始图像(这意味着当我有文件的数据和文件的数据如何我可以添加为我可以再次打开图像)

nota:代码仅用于我如何将灰度格式图像转换为二进制我将在更新后将其更新阅读数据



我尝试过:



hey friends
I get start working with opencv using c programming
-firstly ,i convert image format greyscale pgm to binary lack and white
-i want getting only the data of image without the header? without changing the proprieties of the image
-if opencv have a function for that is good ;
but if it don't have so i think use 2 buffer one for header and the 2 for data after i save each one for a file (file from header and one for data)
but the probem here is after how i can return to the initial image (it means when i have file for data and file for data how i can additionnel to be i can open again the image)
nota : the code is only for how i convert greyscale format image to binary i wil after update it to be read ony the data

What I have tried:

#include "stdafx.h"
#include <iostream>
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <stdio.h>
#include</iostream>


int _tmain(int argc, _TCHAR* argv[])
{
	//load image
	IplImage* im_gray = cvLoadImage("lena512.pgm",CV_LOAD_IMAGE_GRAYSCALE);
	//convert to grey
		//convert to binary 
	IplImage* im_bw = cvCreateImage(cvGetSize(im_gray),IPL_DEPTH_8U,1);
	cvThreshold(im_gray, im_bw, 128, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);
	//save to disk
	cvSaveImage("image_bw.pbm",im_bw);

推荐答案

如果你是谷歌,你会发现有关 pgm标题的有用信息。它粗略地说pgm文件以格式标识符(即魔术数字)(P1-P7)开头,它告诉你格式类型,然后是一些新的行或空格分隔的更多细节。



通常不需要分隔标题和数据。如果你想转换图像你应该找一些库。



这个 Q& A 可能会激励您完成下一步。
If you Google you would find this useful information about pgm headers. It says roughly that the pgm files starting with a format identifier aka "magic number" (P1-P7) which telling you the format type and after it some further details which is new line or white space delimited.

Normally the separation of header and data isnt needed. If you want to convert the image you should look for some library.

The link to some C# code in this Q&A might inspire you to your next steps.


这篇关于Opencv库,获取没有标题的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆