LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interpolate Pixel


@paul_a_cardinale wrote:

More lookup, less multiply:

...


By the way your new algorithm produces slightly different result than the old one (at least comparizon not equal, somethig may be wrong with rounding), and more slow than the previous (rougly 20% on my PC - 120 ms vs 100 ms before when 256x256 image scaled by factor 0,9):

Screenshot 2024-04-22 23.18.19.png

 

Anyway, I checked this with checkerboard and test image, and now I see effect of the gamma (on the screenshot it may wrong appear if scaled in browser), this is gamma 2,2 and scale factor 0,9:

Screenshot 2024-04-22 23.19.33.png

and regular image looks normal with such gamma, at least visually:

Screenshot 2024-04-22 23.20.10.png

So, you're on the right way.

0 Kudos
Message 51 of 95
(307 Views)

I took a picture of a gray scale with my Nikon D780, then checked the RGB values:

% Reflectance   RGB value

     2.5         27

     5           38

    10           68

    20          113

    40          157

    80          203

Which works out to a gamma of about 1.9

Message 52 of 95
(290 Views)

@paul_a_cardinale wrote:

More lookup, less multiply:

paul_a_cardinale_0-1713815010044.png

 


I didn't noticed that you turned parallelization for RGB loop on, therefore overall performance was a bit slower. And also you have 1024 weighting steps, now everything clear for me.

 

As an idea for small performance improvement I would like to recommend to replace Threshold 1D Array where you reapplying gamma with binary-search based version like was shown in DLL. This will give you a little bit. In addition, if you don't need a very high precision, then you can omit "fractional part calc" and output direct integer index, which will almost the same (max difference in compared with "reference Threshold 1D will be only 1).

As exercise, I've made Malleable VI, which can accept both U32 and U64. The only "challenged" part was - how to switch between fast and accurate versions, so I added "Switch" which is numeric, and if not connected, then fast version used, and if BOOLEAN connected here, then accurate, because we will be in "Ignored" case:

thr1.png

back side of the medal:

thr2.png

Advantage is that we can avoid comparison (which also takes time). But I'm not sure that this is most elegant way to do this, but I like this more than polymorphic VI (welcome for comments and notes).

On my PC this VI running 3-5 times faster than original. Source in attachment.

Message 53 of 95
(265 Views)

@Andrey_Dmitriev wrote:

@paul_a_cardinale wrote:

More lookup, less multiply:

paul_a_cardinale_0-1713815010044.png

 


I didn't noticed that you turned parallelization for RGB loop on, therefore overall performance was a bit slower. And also you have 1024 weighting steps, now everything clear for me.

 

As an idea for small performance improvement I would like to recommend to replace Threshold 1D Array where you reapplying gamma with binary-search based version like was shown in DLL. This will give you a little bit. In addition, if you don't need a very high precision, then you can omit "fractional part calc" and output direct integer index, which will almost the same (max difference in compared with "reference Threshold 1D will be only 1).

As exercise, I've made Malleable VI, which can accept both U32 and U64. The only "challenged" part was - how to switch between fast and accurate versions, so I added "Switch" which is numeric, and if not connected, then fast version used, and if BOOLEAN connected here, then accurate, because we will be in "Ignored" case:

thr1.png

back side of the medal:

thr2.png

Advantage is that we can avoid comparison (which also takes time). But I'm not sure that this is most elegant way to do this, but I like this more than polymorphic VI (welcome for comments and notes).

On my PC this VI running 3-5 times faster than original. Source in attachment.


Thank you.  You anticipated my next question (I was going to ask if anyone already had a replacement for "Threshold 1D Array" that used a binary search and didn't interpolate).

Note  however that in this case, the "accurate" version is essential.  The fast version gives wrong results near the edges:

 

Fast version:

paul_a_cardinale_0-1713878810646.png

 

Accurate version:

paul_a_cardinale_1-1713878838721.png

0 Kudos
Message 54 of 95
(257 Views)

I think I'm done.

Many thanks to all those who contributed.

Message 55 of 95
(252 Views)

@paul_a_cardinale wrote:

I think I'm done.

Many thanks to all those who contributed.


You're welcome and congratulations!

The only question — why do you have array miltiplication here:

Screenshot 2024-04-23 16.20.59.png

and not there:

Screenshot 2024-04-23 16.21.17.png

?

0 Kudos
Message 56 of 95
(240 Views)

Probably neglectable but:

wiebeCARYA_0-1713887252886.png

Why build a 12 byte (3XI32) array and convert it to a 3 byte array (3XU8)?

 

wiebeCARYA_1-1713887338471.png

Using Split Array or Array Subset will be more efficient. Delete From Array always copies the array to the outputs, where the alternatives return subarrays.

 

The last 3 Delete From Arrays are redundant, as the for loop won't loop over the 4th element anyway.

0 Kudos
Message 57 of 95
(225 Views)

wiebe@CARYA wrote:

 

Using Split Array or Array Subset will be more efficient. Delete From Array always copies the array to the outputs, where the alternatives return subarrays.

 

This one will not improve much:

Screenshot 2024-04-23 18.29.53.png

But this roughly 10% for performance improvement:

Screenshot 2024-04-23 18.31.23.png

Message 58 of 95
(215 Views)

@Andrey_Dmitriev wrote:

But this roughly 10% for performance improvement:

Screenshot 2024-04-23 18.31.23.png


Nitpicking: To remove some diagram clutter, all we need is a single "1" diagram constant the the "3" can be left unwired. 😄

I also doubt that the "delete from array adds any value, because the deleted element is probably zero.

0 Kudos
Message 59 of 95
(203 Views)

OK.  Maybe now I'm done.

paul_a_cardinale_0-1713898410531.png

0 Kudos
Message 60 of 95
(192 Views)