07-17-2013 12:13 PM
Hello,,,
actually i am writing a program for image processing in c++ and try to make a DLL . My idea is to use labview for acquiring and displaying the images and use c++ for calculation because i think if i use dll the time will be shorter than using labview VI's... i succeed in obtaining results,,, but the processing time became longer than using labview VI's for processing.... This problem occurs from using the image 2d array in the following style:
for (j = 0; j < row; j++)
{
for (i = 0; i < col; i++)
{
A[j*col + i] = a[j*col + i];
}
}
}
because of the consideration of memory allocation....
My question is: how can i use the image 2d array as same in c++.... I mean how to write it in this form A[j][ i] using pointer without make confusing labview memory...
thanks,,,
07-18-2013 01:24 AM
Hello M.A.A.M,
I am attaching the DLL, C++ source code and Labview VI that uses the DLL to add some manual constant to 8-bit image using pointers.
Hope it helps you.
Best regards,
K
07-18-2013 03:42 AM - edited 07-18-2013 03:44 AM
I forgot to add some comments to the previous post:
As far as i know, a lot of libraries in labview are written in c++ an c. So, i don't think you will see very much performance gain when comparing the built-in functions to other functions in let's say OpenCV. I always wanted to know if labview uses OpenCV libraries, since there is some reference to it in the documentation? If you will be using your custom functions, you should have some experience to write clean, memory nonleak code.
The second comment is that you should use vectors instead of arrays in c++ as it is (in my opinion) easier to manipulate with. 2D array is just a representation. The values that are written in memory more resemble the "vector pattern". So, incrementing the pointer, moves to the next block in memory space (depends on the variable type).
Best regards,
K
07-18-2013 07:51 AM
thanks sir,, i will try and inform you by the results,,, thanks again...
07-18-2013 07:55 AM
unfortunatily iam using labview 2009,,, please can you attach an the block diagram as print screen image,,, sorry for disturbance,,,,
07-18-2013 08:19 AM
I have attached the 8.6 version.
Best regards,
K
07-18-2013 09:39 AM
Thanks sir,,, appreciated,,, if possible can you write your e mail ,,, i think i need your evaluation....
07-18-2013 12:59 PM
here i attached an example to show how i write the code,,, the information of position is signficant for my work,,, also my experience in c++ is not enough,,, if there is away just to write the image like nb [ j ] [ i ] it will be helpful for me,,,
thanks,,,
07-18-2013 04:22 PM
@M.A.A.M wrote:
here i attached an example to show how i write the code,,,
well, my recommendations are:
(take a note – I set border to zero, you should use LineWidth as described in the NI example above)
Also you can use pure IMAQ Vis for your calculations. They are pretty fast, because already based on DLL. This code functionally the same as code above:
Hope it helps.
Andrey.
07-18-2013 11:10 PM - edited 07-18-2013 11:12 PM
thanks Andrey,, i use 2d array because after several image processing steps ,,, such like stretching i will obtain paricle ( see the attached image).... in my opinion is : i can track those edges if i apply some tracking algorithm,,,, like this
if (nb[(j * col) + i]==0)
{
for (int j= 1; j< row-1; j++ )
{
for (int i = 1 ; i < col-1; i++ )
{
ip = (j*col)+i+1;
im = (j*col)+i-1;
jp = (j*col)+i+col;
jm = (j*col)+i-col;
}
}
}
so i can search in side the image for the location of the edges....
so sir if there is some way to write the image like 2d array this will be helpful... usually i have something wrong when write the image like this : image [ j ] [ i ],,,,,,, i am keeping searching for a solution during the last two months,,,
but nothing changed... i have to keep trying and trying...
( sir, iam student and this is not my option,,,, just i have to do it like 2d array )
thanks for alllllll