简体   繁体   English

使用Octave从csv文件读取图像

[英]Read images from a csv file with Octave

I want to read the training.csv file with Octave for the Kaggle competition . 我想阅读Octave的Kaggle比赛training.csv文件。 The file contains 16 fields. 该文件包含16个字段。 First 15 are the coordinates of keypoints. 前15个是关键点的坐标。 The 16th is is the image, which is 9216 numbers (0 to 255) separated by space. 第16个是图像,它是由空格分隔的9216个数字 (0到255)。

Tried, but with no luck the followings: 尝试过,但没有以下几点:

 - data = csvread('training.csv'); 

 - data = dlmread('training.csv', ',');

 - [l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15, image] =
   textread("training.csv", "%f %f %f %f %f %f %f %f %f %f %f %f %f %f
   %f %s", "delimiter", ",", "endofline", "\n", "headerlines", 1);

Note: 注意:

Thanks, 谢谢,

This post contributed greatly to figure this out. 这篇文章为解决这个问题做出了巨大贡献。 The key is to: 关键是:

  • Remove the header row 删除标题行
  • Replace the ",," (double commas) with "0" "0"替换",," (双逗号)
  • Replace "," (single comma) with " " (space) "," (单个逗号)替换为" " (空格)
  • The code to read the file 读取文件的代码

    fn = 'training_space.txt'; M = dlmread(fn);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM