LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Same image fills output array

Hello everyone I am making a program that scans 12 pictures and extracts 42 portions of those images, I have to mention that while coding / testing my code the image display did show the current extracted portions of the image and until I finished the code I realized that all the elements of my output array were wrong, because it overwritten all the elements with the last extracted image.

I have dealt with this kind of situation before by saving every picture, but I wonder and after not finding an answer I make this post to answer the next question. Is there a way to keep multiple images in memory (to later save in an array like my example) while only declaring one imaq create buffer?

 

Code.png

 

 

Array.png

0 Kudos
Message 1 of 6
(984 Views)

It is always frustrating (and almost impossible) to answer questions about LabVIEW code without access to the code under question.  Posting a picture of the code is rarely satisfactory -- images are small, they are not "editable", and they certainly are not "testable".

 

Every "image" you want to view/save has to be saved somewhere in memory.  The "IMAQ Create" creates a pointer that can be "instantiated" by placing an actual "image" (for example, from a Camera) in it.  You can put multiple Camera "frames" in this (single) storage location, but you are, indeed, overwriting the previously-stored data saved there.

 

If you want to take 12 images from a Camera, then you need an array of 12 IMAQ "Images", one per Camera Image.  If you plan to process these 12 images to generate 42 "sub-images" (which you haven't described), you'll need an additional 42 "IMAQ Create" for each sub-Image.

 

Bob Schor

0 Kudos
Message 2 of 6
(966 Views)

I am aware I didn't share my code, found it pointless sharing a code that only works with some pictures that I am not allowed to share. And regarding the answer I think it's way faster saving the images for later processing rather than making 504 buffers for the sub images even worse if you have to scale that amount of pictures nobody would want to do it one by one.

I was just curious if there was another way around. Anyways thanks for the fast response and also for taking your time to reply to my doubt. 

0 Kudos
Message 3 of 6
(960 Views)

Again, by not posting code, it really isn't clear what you are trying to do (though I think you did a much better job describing the "what" in your most recent reply).

 

Your mention of 504 sub-images suggests that you can "do it all" with two IMAQ Create buffers.  As I gather from your reply, you start with 12 (camera or other) Images that you will sub-divide into 42 "sub-Images".  Create one Camera Buffer and one SubImage Buffer.

  • Outer For Loop reads one Camera Image (which need not come from a "camera", but represents the "big image" you are going to sub-divide into 42 pieces).
  • Pass this Image into an inner For Loop that extracts the 42 sub-Images from the Camera Buffer and saves them to disk for subsequent processing. I'd suggest a naming scheme that incorporates the Camera Buffer # and the Image Buffer #.

Bob Schor

 

0 Kudos
Message 4 of 6
(938 Views)

The way you mention to save the pictures into my computer isn't something new to me, As I mentioned I have found ways to solve this "problem" before using state machine structure, but I have a feeling that I am misunderstanding something that perhaps is obvious. (uploaded a zip with some images just for the code to work).

 

The output array has the same behavior as before. After reading all the images It presents an array filled with only the last picture opened by the program.

 

Maybe I am just confused because before using Vision and Motion VI's I used Graphics Formats where you can easily read the image and save either the 2D array or the image information. That way you could access any image information without the problem of it getting overwritten unless you actually intended to "save" the edited information.

 

Brunito_Perezs_0-1685942944419.png

 

My question is, is there a way to mimic what I used to do with the Graphics formats Palette? Tomorrow I will try recreating an example with this palette in case my post isn't clear enough.

0 Kudos
Message 5 of 6
(917 Views)

If you use IMAQdx to read an Image, you can also use IMAQdx to write that Image as a JPEG, BMP, PNG, etc.  It's not clear (to me) how you sub-divide the 12 "big images" into 42 sub-images, but you could also write out each of the sub-Images as a separate Image file (using IMAQdx), so that at any one time, you'd have only two IMAQdx Image (buffers), one holding one of the 12 "big" images, and the other holding one of the 42 "sub-images", each lasting just long enough to have the Image Data stored therein written to disk.

 

Now you can easily use the Graphics File I/O functions to read these (or, at least, I hope that is the case!).

 

Bob Schor

0 Kudos
Message 6 of 6
(894 Views)