From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how would i go about resizing an image of unknown dimensions to a specific dimension and saving it?

how would i go about resizing an image of unknown dimensions to a specific dimension and saving it? I would prefere to use .jpg format. I got some imageresize thing from http://www.geocities.com/gzou999/ but it didnt end up working for some reason. If anyone has another method, please let it be know!

Thanks,
-Mark
0 Kudos
Message 1 of 14
(3,512 Views)
What's wrong with Image Resize.vi ?

George
George Zou
0 Kudos
Message 2 of 14
(3,512 Views)
Unfortunately, image formats can vary. It is important to know the kind of image with which you are starting. If the image format is arbitrary, your task is going to be difficult to do strictly in the Base IMAQ package. You have to start out with some knowledge of the image. If it is not a BITMAP or a JPEG type of image that you are starting with, you will have to use more advanced graphics tools, or find a description of the binary form of your image and work with the raw data, writing your own algorithm. I have never used the Vision package, but I am willing to bet that it will have all the tools you need, provided you can afford them for this project.

Perhaps you could be a bit more specific about your problem. Can you answer a few pertinent questions, e.g. Where did the image originate? What kind of processing are you doing? Do you have time to use other tools on your computer to determine the image type and perhaps convert it to a type that the base IMAQ package can read?

Once you have a BITMAP or JPEG, you can do the resizing with the base IMAQ tools, or use gzou999's tools. The simplest way to do it yourself with the base IMAQ tools, is to unflatten the image and then decimate the resulting pixmap matrix. This will not give you the full control you desire, but it is the cheapest, and least time-consuming method I know to get some control over the image size. If you are unwilling to accept integer ratio progression of size options, you will have to develop your own interpolation algorithm. In that case, you are probably better off to buy a LabVIEW tool to do the job. Once you have the reduced image, you can flatten it and save it as a jpeg using the "save flattened image" as JPEG vi.

I am working on a machine that doesn't have LabvIEW on it or I would provide specific names for the vis. I believe the flatten and unflatten functions are found in the picture and sound controls subpalette and the reading and writing jpeg files are found in the IMAQ function subpalette in the image format subpalette.
jc
Mac 10.4
LV7.1
CLD
0 Kudos
Message 3 of 14
(3,512 Views)
everytime i attempt to use it.. labview just crashes... not sure why.
0 Kudos
Message 4 of 14
(3,512 Views)
Im actualy going to have the user select a .jpg image to resize.. then im having it resized to 250x120.
0 Kudos
Message 5 of 14
(3,512 Views)
well.. more speficly, it crashes after i resize and then try to save the resized file.
0 Kudos
Message 6 of 14
(3,512 Views)
Heres the picture of the block diagram part where i am saving... i noticed if i took the write .jpeg out then it works fine... i dont know what im doing wrong..
0 Kudos
Message 7 of 14
(3,512 Views)
The diagram looks ok.

What OS are you using?

Try it on WinXP, it should work.
George Zou
0 Kudos
Message 8 of 14
(3,512 Views)
Im running xp home currently, although the final product would be in xp pro.. but.. not really a difference
0 Kudos
Message 9 of 14
(3,512 Views)
My apology. It crashes on me too in LabVIEW 6.0.2. It complains about an NI CIN function can't be found. I haven't run into this LabVIEW bug for a long time, and forgot all about it. So my VIs only works for LabVIEW 6.1 and 7.

Good luck.

George
George Zou
0 Kudos
Message 10 of 14
(3,512 Views)