LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create a RAWpic-file with header(cluster of 8elements) and 2D Array?

I have created a cluster with 8 "I32"elements (Header). I also got picture information into a 2D array (i converted information from a ROI into a 2Darray("Image pixels(I16)")
Now I want to create a RAW picture file (first the header information followed by the picture information.)
I think I have to convert the Header-cluster into an array with "cluster to array". But even this is not possible(Info:"you cannot combine 2 different clusters"). Then I have to combine the 2 arrays with "insert into array"??? But the header array would be a 1Darray if the "cluster to array conversation" works and the picture information is 2D.
Can anyone help me please?
0 Kudos
Message 1 of 5
(2,303 Views)
I would expect that the main problem you would encounter is actually writing the file. LV has a very specific way for saving arrays and I doubt flattening an array to a string and saving will help you. Do you have any solution for that?

Assuming you do, a cluster with 8 I32 elements should not give you problems when converting to an array. I don't know the error you're refering to.

I still think the basic problem would be saving the file. Is it possible to save as a BMP instead (there's a VI for that in the graphics palette)?
If not, I suggest you post your code.

___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(2,298 Views)
I think this is actually pretty straightforward, barring any byte-order issues. Attached is an image that demonstrates what I think jotthape wants to do.

The key is to let multiple Write File nodes do the work for you. There's no need to combine all the data into a single structure for the write, and avoiding that makes things easier in this case, because you don't have to worry about some of the data being I32 and the rest being I16.

Give this a shot,
John

P.S. It does seem likely that you will run into byte-order problems if you want to read your custom RAW file in using some other piece of Windows software. You can check the forum and the NI site for info on byte order, then ask a new question if you're still having a problem.
Message 3 of 5
(2,290 Views)


@Johnner wrote:
I think this is actually pretty straightforward, barring any byte-order issues...
It does seem likely that you will run into byte-order problems if you want to read your custom RAW file in using some other piece of Windows software.


John, I don't really deal with this, so bear with me a second - when you save like that, won't LV use its own format to save the array? If so, this will not be a real RAW format, right (i.e. readable with graphics programs)? Is that what you meant in your P.S.?
What I'm saying is that I don't think there will be a problem saving, but there will be a problem with reading from other programs. You think this will only be a byte order issue? Am I missing something about the way LV saves data using the write VI?

___________________
Try to take over the world!
0 Kudos
Message 4 of 5
(2,280 Views)
tst,

I feel your pain. Honestly, I believe that binary file I/O in LabVIEW (datalog files and headers and all the different ways that Read File and Write File can be used) is unnecessarily complex from a developer perspective, though I'm not sure I can make any suggestions on simplifying things right off the top of my head. All that functionality is not a bad thing.

But no, with the approach I demonstrated, LabVIEW will not include array size info or any other header content in the saved file. I could include the array size info by wiring a TRUE to the header input.

As far as being a "real" RAW format, you probably know better than I do. I happen to know that TIFF is a pretty open format, in terms of being able to define an arbitrary header, and I am just assuming that something similar is in effect for the files that jotthape is working with. He/she sounded fairly confident about the desired file structure.

Take care,
John
0 Kudos
Message 5 of 5
(2,267 Views)