So what I want to do is load a JPEG, convert it to a 2D array of colors (grayscale or not, doesn't matter) - just so I can tell where an outline of a shape is. Eventually I want to send the coordinates of the outline of the shape over serial, but I'm not quite there yet.
I know y'all don't like old revived threads, but I was using code that was found in an earlier thread that converts a JPEG to a 2D grayscale array and couldn't get it to work as I thought it would. When I try to open the attached jpg (untitled) in the attached vi, it only shows 29 rows of data in the 2D array which is not the whole picture.
I'm using the evaluation version of LabVIEW 2009 and have little to no experience in image processing, so forgive me if my vocab sounds like I'm a little (or a lot) lost.
If I understand correctly what you're trying to do is you want the a 2D array which is each pixel in an element. You won't get that from doing a straight conversion to a 2D array from Jpeg because the jpeg is compressed data, hence why you got only 29 rows of data and not the whole picture. From a bitmap to 2D array should give you what you need to look for the outline.
Another option is to use the vision module NI offers... there are very useful functions to do pretty much everything you could imagine in image processing.
I don't think the OP has IMAQ, just plain LabVIEW.
Here's what I had in mind. Remember, that the image is 24 bit color, so you might want to split it into three arrays: R, G, and B. If the image is greyscale, all three contain the same info, so one (e.g. R) will suffice for processing.
Alten, you're right. I only have plain LabVIEW. But the image will not always be grayscale, converting it to grayscale just helps me find the outline. The problem with what I have is that I don't seem to have the whole picture so I'm wondering if what Jchec said is the problem. Because it's a jpg will not get the whole picture?
I've attached a screenshot of what I see, and the part circled in red makes me think I'm not seeing the bottom of the square (the <10 numbers is what I'm going to be looking for for as the outline). Everything goes to 0, which would indicate black?
Because it's a jpg will not get the whole picture?
Of course my method will get the full picture. That has nothing to do with jpeg compression.
The code in the original post has a problem in that N seems incorrectly calculated. (Try to divide by 3 instead of 8 at the Quotient&Remainder. :))
The code in the original post has a problem in that N seems incorrectly calculated. (Try to divide by 3 instead of 8 at the Quotient&Remainder.
Yes, that's what I caught. >_<