How do I create a header file that is associated with a set of images captured from a camera?

1 view (last 30 days)
I have been asked to acquire and store a set of images for processing in matlab. I need to have an associated header file that contains general information about this set of images (number of images, rows, columuns, time, etc). What is the best way to accomplish this and how do I keep these images "attached" to this header file? Im new to image processing and could use a little guidance on how to do this. If further clarification is needed please let me know!
Kind Regards

Accepted Answer

Aditya on 23 Jan 2023
Edited: Aditya on 23 Jan 2023
Hi Scott,
I understand that you want to understand how to organize the image data that you are acquiring. At the end it all depends on your personal preference. Here is a general practice that I have seen being followed in computer vision community:
Organizing data
The set of images will be stored in a folder. The folder will contain the header file. This is the simplest way to keep the images "attached to the header file". Here is the folder structure. Whenever you share the dataset, you will share the entire folder. All programming languages, including MATLAB have excellent support for file/folder operations.
|-- image set-1
|-- image-1.png
|-- image-2.png
|-- ...
|-- header file
|-- image set-2
|-- image-1.png
|-- image-2.png
|-- ...
|-- header file
|-- ....
|-- ....
|-- image set-n
|-- image-1.png
|-- image-2.png
|-- ...
|-- header file
Header File
This is also based on your preference. My preferred way of doing this is to use json files because of following reasons:
json files are easy to read in programming languages. You can directly load contents of a json file to a struct using jsondecode. A simple example showing same :
function result = read_json(fname)
fid = fopen(fname);
raw = fread(fid,inf);
str = char(raw');
result = jsondecode(str);
Similarly, you can easily write a MATLAB struct to a json file using jsonencode as shown in documentation examples.
json files are easy to share. They are human readable and can be understood by simply opening them. All programming languages have excellent support for reading and writing to a json file.
To summarize
  1. Store a set of images in a folder and save the header file in the same folder.
  2. Store all the information that you want in header file inside a MATLAB struct and write that struct to a json file.
  3. Whenever you want to share the set of images, share the entire folder.
  1 Comment
Scott Kaiser
Scott Kaiser on 23 Jan 2023
Thank you very much for you support here. This makes perfect sense and seems well organized.
Kind regards,
Scott Kaiser

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!