I am working with images and computing radon transform for an object. The function that computes the transform accepts vector as input:
pixel p;
vector<pixel> segObj //segObj is the object segmneted from the image
pixel is a user-defined struct defined as:
struct pixel
{
float x, y; //x,y coordinates of the pixel
};
Currently, I am doing an element wise assignment to the vector:
for(int ix=0; ix < element_count; ix++)
{
f.x = xCoordArray[ix];
f.y = yCoordArray[ix];
segObj.push_back(f);
//xCoordArray and yCoordArray are computed separately
}
The for loop makes it slow when dealing with large images. Is there a way to assign xCoordArray and yCoordArray directly to vector<pixel>segObj
I am not expereinced with the use of vectors so any help would be appreciated.
Also,
If xCoordArray, yCoordArray can be computed as vectors, is there a way to join them so that each vector index as two values.
You can create an input iterator producing
pixelobjects and assign those directly. You could initialize the objects directly using something along the lines of this:That said, I somewhat doubt that this is indeed the bottleneck: did you profile your code or are you suspecting that this is the problem?