VisionWorks -- Histogram

I am trying to use VisionWorks Histogram and little puzzled in the usage part. My understanding is like this (Please correct me):

vx_size numBins = 10;
vx_uint32 offset = 10;
vx_uint32 range = 256;
// Create Object
vx_distribution vx_dist = vxCreateDistribution (Context, numBins, offset, 
range);

// Create Node
vx_status status = vxuHistogram (context, img, vx_dist);

Spec says that vxuHistogram() takes vx_distribution as [out], does that means vxuHistogram() creates object internally? If the answer is ‘Yes’ than how would i pass numBins, Offset and range of my choice?

Also. how can i access the output of histogram result? Any example would be really helpful.

Hi,

Histogram document is at
[i]> VisionWorks API

Khronos OpenVX 1.1 API
OpenVX API Modules
Vision Functions
Histogram[/i]

  1. You need to create a distribution object first and vxuHistogram() will be able to save the histogram results into this object. (In your sample, that is vx_dist)
  2. numBin is assigned when creating.
  3. vx_distribution doc is located at
    [i]> VisionWorks API

Khronos OpenVX 1.1 API
OpenVX API Modules
Basic Features
Objects
Object: Distribution[/i]

Thanks @AastaLLL i figured this out and the code looks like this:

// Create Object
vx_size numBins = 10;
vx_uint32 offset = 10;
vx_uint32 range = 256;
vx_distribution vx_dist = vxCreateDistribution (Context, numBins, offset, range);

vx_graph graph = vxCreateGraph(context);
vxHistogramNode(graph, img, vx_dist);
vxVerifyGraph(graph);

vxProcessGraph(graph);

// Read the data (I am planning to make this Custom kernel/Node, so that i can play with the data inside this node.)
vx_map_id map_id;
vx_int32 *ptr;
vxMapDistribution(vx_dist, &map_id, (void **)&ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, 0);
// use ptr, like ptr[0]
vxUnmapDistribution(vx_dist, map_id);

Could you please give me your blessings for the above code? Thanks.

Hi,

I didn’t try the code for you.
But it looks correct.