Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

PietH

Member

02-28-2021 02:01 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi Vision cracks 😉

It would be great if you could help me!

I've worked with the NI Vision Development Toolkit for a long time. So far I have only used the build in filter functions.

I now have a special problem and I still have no idea how I could solve it, or whether it is even possible with vision.

I have an initial image from which I want to create a new filtered image.

The results of the calculations with the center pixel on image A should be written into the pixel at the same position in the new image.

**Pixel by Pixel Processing:**

- Calculation of the mean value from the center pixel and the surrounding 8 pixels (green 3x3 area in the attached image).
- Calculation of the mean value from the 16 surrounding pixels (orange area around the green 3x3 area)
- Dividing the mean value from 1. by the mean value from 2.

(In the attached picture I call it A divided by B) - Write the result in a new picture

The calculation should run pixel by pixel like a sliding window, calculate all pixels in the image and create a new image from the results.

Is that possible?

Best

Peter

Solved! Go to Solution.

RavensFan

Knight of NI

02-28-2021 03:03 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Sure it is possible. Have you started it?

Think of a set of loops where you act on the original array pixel by pixel, and put the results in a new array.

Solution

Accepted by topic author PietH

wiebe@CARYA

Proven Zealot

03-01-2021 03:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

NIVision does support a custom kernel operation, although IIRC it's hidden and hard to use. Probably documented here: Convolution Kernels - NI Vision 2019 for LabVIEW Help

A kernel of all 1's, divided by the number of 1's should give the average.

I'm pretty sure running two build-in kernel operations and then dividing the results will be faster than any DIY solution. But maybe not... Less work for sure.

DIY (performant) kernel operations are much trickier than you'd think.

LabVIEW Programming ((make LV more popular, read this)

03-01-2021 05:13 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thanks for your answer.

That it works with array operations is clear.

But I wanted to avoid that. However, this is time-consuming and is not as precise as when I do it directly with Vison. Do you still have an idea how to solve it with vision?

Best

Peter

03-01-2021 05:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thanks for your help.

I know the document about convolution kernels. I use them very often.

It is also very easy to use an average filter.

The problem here, however, is to average two different areas around the center pixel in the image, to divide the 2 mean values and to write the result in a new image and that in one work step, from one pixel to the next.

Maybe you have an example how to do it?

Best

Peter

Solution

Accepted by topic author PietH

wiebe@CARYA

Proven Zealot

03-01-2021 09:10 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Calculate the 2 kernels in 2 images. Then use the IMAQ Divide VI to divide the two.

Of course care should be taken to use the correct data types.

I can't make an example, I don't have IMAQ installed at the moment.

LabVIEW Programming ((make LV more popular, read this)

Solution

Accepted by topic author PietH

RamonG

Member

03-01-2021 09:26 AM - edited 03-01-2021 09:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Something like this should work. Be careful with divisions by zero with SGL images, the image indicator can slow down LabVIEW.

*Edit: reading your reply you want to create a new image so a new buffer should be connected to the Image DST input for IMAQ Divide vi.

03-05-2021 01:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thanks a lot. I will try it out!

03-08-2021 05:55 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi Ramon,

thanks a lot.

It works good and its fast!

Peter

03-08-2021 06:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thank you all for your help!

I learned a lot. Kernels are very powerful and versatile.

Creating a convoltion kernel for averaging is easy!

But what about the maximum value?

If I want to calculate a maximum value from the 9 pixels and the 16 surrounding pixels.

Is that possible with vision?

Pixel by Pixel Processing:

- Calculation of the max value from the center pixel and the surrounding 8 pixels (green 3x3 area in the attached image).
- Calculation of the max value from the 16 surrounding pixels (orange area around the green 3x3 area)
- Dividing the mean value from 1. by the mean value from 2.

(In the attached picture I call it A divided by B) - Write the result in a new picture