LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

need help with my image filter

hi guys,

 

so i'm making this image filter for school in Labview but can't get it to work properly, to do the filtering i'm using a formula node, which in my eyes is easier then with only labview functions.

 

for the C code i'm following this website: http://lodev.org/cgtutor/filtering.html

 

i don't copy exact every line, i'm only copying the lines i need. note that i don't use the "ColorRGB" class because it doesn't exist in a formula node, i do the filtering on a black and white image so don't really need it.

I adjusted to code so that it would work in my formula node.

if i run the vi and select the attached image file (can't attach .bmp files so i included a link for the img file) for input then it just returns the original image, which is good and also bad, good because the code works in some way but bad because it doesn't do any filtering or such.

Could anyone please look into this and give me some tips or tell me what i'm doing wrong?

and if anyone knows how to do this in RGB you are always welcome to give me tips. 🙂 

 

used image file: http://www13.zippyshare.com/v/74810991/file.html  (can't attach bmp files so i uploaded it quickly)

 

(btw i know there is this toolkit called vision which has many functions that could help me, but the teacher already said we can't use that)

 

i hope somebody can assist me in this and willing to give me some help.

 

Grtz Stino

 

 

 

 

 

0 Kudos
Message 1 of 14
(3,599 Views)

Why don't you use the NI Vision Development Module ?

The filters you use are allready implemented there and I'm pretty sure it will run with better performance.

 

 

Christian

0 Kudos
Message 2 of 14
(3,595 Views)

i quote myself: "(btw i know there is this toolkit called vision which has many functions that could help me, but the teacher already said we can't use that)"

 

we can't use vision because we need to learn about the basics and the principels of DSP, filtering and all of that, so that's why we need to code our own filter, so no vision functions allowed or i fail the class. 

0 Kudos
Message 3 of 14
(3,588 Views)

Take a hard look at your last for loop.

0 Kudos
Message 4 of 14
(3,583 Views)

ups

0 Kudos
Message 5 of 14
(3,571 Views)

do you mind telling me what mistake i need to look for? 🙂

i looked at my last for loop but can't see the problem, could u please tell me? 

 

and 'ups' what kind of usefull answer is that? 

0 Kudos
Message 6 of 14
(3,555 Views)

omg that was so stupid, i thought my mistake was in the 4 double loop but it was in the very very last loop, ok so i got that fixed but there is still something wrong because the result is mostly a white image or a messed up image? maybe there is something wrong with the math operations but i can't tell, someone have any tips?

0 Kudos
Message 7 of 14
(3,552 Views)

Yes there are two bugs, I found the other one first but figured if you fixed the result the other would be obvious.  This is homework so only a hint:

 

look at what happens (and does not happen) to pixel. 

0 Kudos
Message 8 of 14
(3,542 Views)

Just one more advice:

Look at the format of the "image" array. The way how to use the values from this array depends on the "image depth" parameter. 

In your case, because the image is 8bit, you need to use the "colors" array containing the real RGB value.

Look at the Help for the "Read BMP File VI", you should be able to properly handle your pixels from there.

Cédric | NI Belgium
Message 9 of 14
(3,538 Views)

 


Darin.K wrote:

Yes there are two bugs, I found the other one first but figured if you fixed the result the other would be obvious.  This is homework so only a hint:

 

look at what happens (and does not happen) to pixel. 


the first bug was that i had to use the 'result[][]' array instead of the 'image[][]' array in my last loop, right?

 

the 2nd bug I really can't find :s been lookin at it for almost an hour now and trying new stuff but nothing works, 

first i thought i had to put this line " result[x][y] = min(max(int((factor2 * pixel) + bias2), 0), 255);"  inside the for loop above but that didn't fix my problem,

maybe the problem is in my 'imageX' and 'imageY' variable, i don't know? any more tips?

I'm sorry for being such a newb but programming isn't my strongest quality.

 


cedhoc wrote:

Just one more advice:

Look at the format of the "image" array. The way how to use the values from this array depends on the "image depth" parameter. 

In your case, because the image is 8bit, you need to use the "colors" array containing the real RGB value.

Look at the Help for the "Read BMP File VI", you should be able to properly handle your pixels from there.


 thanks for pointing that out for me, so I connect the 'totalpix' array with the 'colors' array from the image data instead of the 'image' array, that's correct right?
 



 

0 Kudos
Message 10 of 14
(3,530 Views)