之前看到



http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/

提供的人工图像分割的.seg格式的文件,他们提供了linux系统下面的matlab代码,什么的,但是我们要在windows平台下面用就比较麻烦,就心血来潮写一个试试,还请大牛们指点一二啊,嘿嘿嘿

下面是SegHuman.h

/*
// # Reload me!
//
// SEGMENTATION FILE FORMAT
// David Martin
// 8/2/2001
//
// This document describes the segmentation file format. Segmentation
// files end in ".seg".
//
// The overall structure of the file is as follows:
//
// <header>
// data
// <data>
//
// The first part of the file is the header. The header is ascii text,
// and can contain comments. The comment character is '#'. The header
// is separated from the data with a line containing the literal text
// "data".
//
// The header can contain the following information, in any order:
//
// format {*ascii|binary} {*cr|map}
// date <date string>
// image <int> # image ID number
// user <int> # user ID number
// width <int> # width of image
// height <int> # height of image
// segments <int> # number of segments
// gray {*0|1} # image presented in grayscale?
// invert {*0|1} # image presented with pixel values inverted?
// flipflop {*0|1} # image presented upside-down and backwards?
//
// The {width,height,segments} lines are required. All others lines are
// optional. Default values are marked with a '*'.
//
// The format line describes the format of the data section of the file.
// The default and recommended format is 'ascii cr' (cr = compressed
// row). This document does not describe the other formats, as they are
// probably superfluous.
//
// The 'ascii cr' format is designed to be very easy to parse; it is not
// optimized for space. Use gzip if you want smaller files! Each line
// in the data section contains 4 integers:
//
// <s> <r> <c1> <c2>
//
// All values start counting at 0. <s> is the segment number; <r> is the
// row; <c1> and <c2> are column numbers. The line means that columns
// [<c1>..<c2>] of row <r> belong to segment <s>. Lines of this sort can
// appear in any order, and can be reordered without harm. The only
// restriction is that each pixel must be named exactly once.
//
// END
//
//
*/ #ifndef SEG_HUMAN
#define SEG_HUMAN #include "stdafx.h"
#include "stdio.h"
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <list> #include <iostream>
using namespace std; struct SEG
{
int segment_number;
int row;
int column_number1;
int column_number2;
}; class SegHuman
{
public:
SegHuman(const char* path);
bool LoadSEG(const char* path); private:
string name;
int image_index;
int segments_index;
int height;
int width;
int gray;
vector<SEG> MySeg;
}; #endif // SEGHMAN

下面是:SegHuman.cpp

#include "stdafx.h"
#include "SegHuman.h" #include <iostream>
using namespace std; SegHuman::SegHuman(const char* path)
{
LoadSEG(path);
} bool SegHuman::LoadSEG(const char* path)
{
int st = 0;
FILE* pfile = fopen(path, "r");
if (pfile)
{
fseek(pfile,0,SEEK_END);
int dwsize = ftell(pfile);
rewind(pfile); char* filebuffer = new char[dwsize];
fread(filebuffer, 1, dwsize, pfile); char* pBegin = filebuffer;
char* pEnd = strchr(filebuffer, '\n');
int uiIndex = 1; int st = 0; while (pEnd != NULL)
{ std::string strbuff;
strbuff.insert(0, pBegin, pEnd-pBegin);
if (strbuff.empty())
{
return false;
} if (st==0)
{
if (1 == sscanf(strbuff.c_str(),"image %d",&image_index)) st=1;
}
else if (st==1)
{
if (1 == sscanf(strbuff.c_str(),"width %d",&width)) st=2;
}
else if (st==2)
{
if (1 == sscanf(strbuff.c_str(),"height %d",&height)) st=3;
}
else if (st==3)
{
if (1 == sscanf(strbuff.c_str(),"segments %d",&segments_index)) st=4;
}
else if (st==4)
{
if (1 == sscanf(strbuff.c_str(),"gray %d",&gray)) st=5;
}
else if (st==5)
{
if (0==strcmp(strbuff.c_str(),"data")) st=6;
}
else if (st==6)
{
SEG temp = { -1, -1, -1, -1};
if (4 == sscanf(strbuff.c_str(),"%d %d %d %d",&temp.segment_number, &temp.row, &temp.column_number1 , &temp.column_number2))
{
++uiIndex;
MySeg.push_back(temp); }
} pBegin = pEnd + 1;
pEnd = strchr(pEnd + 1, '\n'); }
delete[] filebuffer;
fclose(pfile); vector<SEG>::iterator iter = MySeg.begin();
for (;iter !=MySeg.end(); ++iter)
{
cout<<iter->segment_number<<' ';
cout<<iter->row<<' ';
cout<<iter->column_number1 <<' ';
cout<<iter->column_number2<<' ';
cout<<endl; }
getchar(); return true;
} return false;
}

下面的任务就是修改代码,把它用在OpenCV中,来显示人工分割的图像啦!

uc伯克利人工分割图像.seg文件解析的更多相关文章

  1. 图片像素对比OpenCV实现,实现人工分割跟算法分割图像结果的对比

    图片对比,计算不同像素个数,已经比率.实现人工分割跟算法分割图像结果的对比,但是只能用灰度图像作为输入 // imageMaskComparison.cpp : 定义控制台应用程序的入口点. // / ...

  2. 细粒度语义分割:ICCV2019论文解析

    细粒度语义分割:ICCV2019论文解析 Fine-Grained Segmentation Networks: Self-Supervised Segmentation for Improved L ...

  3. 全景分割:CVPR2019论文解析

    全景分割:CVPR2019论文解析 Panoptic Segmentation 论文链接: http://openaccess.thecvf.com/content_CVPR_2019/papers/ ...

  4. (转)AVI文件格式解析+AVI文件解析工具

    AVI文件解析工具下载地址:http://download.csdn.net/detail/zjq634359531/7556659 AVI(Audio Video Interleaved的缩写)是一 ...

  5. Dicom格式文件解析器[转]

    Dicom格式文件解析器   Dicom全称是医学数字图像与通讯,这里讲的暂不涉及通讯那方面的问题 只讲*.dcm 也就是diocm格式文件的读取,读取本身是没啥难度的 无非就是字节码数据流处理.只不 ...

  6. Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析

    转自:http://www.uml.org.cn/mobiledev/201211221.asp 今天,我着重讲解下如下三个内容: measure过程 WRAP_CONTENT.MATCH_PAREN ...

  7. kitti数据集标定文件解析

    1.kitti数据采集平台 KITTI数据集的数据采集平台装配有2个灰度摄像机,2个彩色摄像机,一个Velodyne64线3D激光雷达,4个光学镜头,以及1个GPS导航系统.图示为传感器的配置平面图, ...

  8. NIPS 2018 | 程序翻译新突破:UC伯克利提出树到树的程序翻译神经网络

    NIPS 2018 | 程序翻译新突破:UC伯克利提出树到树的程序翻译神经网络 机器之心 ​ 已认证的官方帐号 49 人赞同了该文章 选自arXiv,作者:Xinyun Chen.Chang Liu. ...

  9. 转载:AAC文件解析及解码

    转自:http://blog.csdn.net/wlsfling/article/details/5876016 http://www.cnblogs.com/gaozehua/archive/201 ...

随机推荐

  1. Dynamics CRM2016 站点地图Bug之KnowledgeArticle不显示

    在CRM2016中对知识库功能进行了加强,新加入了KnowledgeArticle的实体,但在学习的过程中发现了微软的一个bug 下图是我在最新的2016online的版本上看到的service下的s ...

  2. ORACLE数据库学习之逻辑结构

     逻辑结构 数据库逻辑结构包含表空间.段.范围(extent).数据块和模式对象. (一)表空间 一个数据库划分为一个或多个逻辑单位,该逻辑单位称为表空间类似于sybase下的设备.(TABLES ...

  3. (一〇九)UIButton的使用技巧 -imageView、titleLabel、圆角等

    UIButton是一个常用控件,使用方法十分基本,但是有很多技巧常常不被注意,本文主要介绍UIButton的一些较高级技巧,用于实现图片和标签显示的美观性等. 开发时常常碰到按钮的下侧或者右侧有标题的 ...

  4. UNIX网络编程——非阻塞accept

    当有一个已完成的连接准备好被accept时,select将作为可读描述符返回该连接的监听套接字.因此,如果我们使用select在某个监听套接字上等待一个外来连接,那就没有必要把监听套接字设置为非阻塞, ...

  5. 关于新版本,iOS10的相关内容,兼容iOS 10 资料整理笔记

    1.Notification(通知) 自从Notification被引入之后,苹果就不断的更新优化,但这些更新优化只是小打小闹,直至现在iOS 10开始真正的进行大改重构,这让开发者也体会到UserN ...

  6. svn 集成 redmine 账户验证的终极解决方案

    svn 集成 redmine 账户验证的终极解决方案 赖勇浩(http://laiyonghao.com) 动机 对于大部分开发团队来说,一般都需要一套 SCM 系统,通常是 svn + redmin ...

  7. eclipse代码恢复(开发程序代码恢复)

    如果误操作,让本地代码丢失了不用怕,Eclipse local history可以恢复. 误删除文件后,直接ctrl+z可以恢复. 拉去代码覆盖了本地,也可以一个一个或者整体进行恢复:http://b ...

  8. A*寻路算法入门(三)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 免责申明:本博客提供的所有翻译文章原稿均来自互联网,仅供学习交流 ...

  9. 【一天一道LeetCode】#73. Set Matrix Zeroes

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...

  10. MyEclipse 报错:Errors running builder 'DeploymentBuilder' on project '工程名'

    并没有更换MyEclipse版本,只是重新卸载了下,然后就报错误,参考了网上的文章 解决版本 .就是删除工程下部署文件