This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

not able to run "Calculate Histogram", algorithm successfully on DM6446

Hello all,

I have DM6446 based custom board. On that board, I am trying to run pre-compiled VLIB and IMGLIB functions.

I have successfully integrated IMGLIB and VLIB algorithms as codecs, and now I am using them from my linux/arm application.

What I am trying to do is, 

1. Convert an YUV 4:2:2(U,Y,V,Y) image to HSL planes using VLIB algorithm, 

VLIB_convertUYVYint_to_HSLpl(yc, width, pitch, height, vlibcoeff, div_table, hue, s, v); 

where, yc -> input YUV 4:2:2 buffer (memory aligned to 64 bit)

             width -> 1024

   pitch -> 1024

   height -> 768

   vlibcoeff -> { 0x2000, 0x2BDD, -0x0AC5, -0x1658, 0x3770 };

   div_table [510] -> { 0, 32768, 16384, 10922, 8192, 6553, 5461, 4681,

4096, 3640, 3276, 2978, 2730, 2520, 2340, 2184, 2048, 1927, 1820, 1724, 1638,
1560, 1489, 1424, 1365, 1310, 1260, 1213, 1170, 1129, 1092, 1057,
1024, 992, 963, 936, 910, 885, 862, 840, 819, 799, 780, 762, 744, 728, 712, 697,
682, 668, 655, 642, 630, 618, 606, 595, 585, 574, 564, 555, 546, 537, 528, 520,
512, 504, 496, 489, 481, 474, 468, 461, 455, 448, 442, 436, 431, 425, 420, 414,
409, 404, 399, 394, 390, 385, 381, 376, 372, 368, 364, 360, 356, 352, 348, 344,
341, 337, 334, 330, 327, 324, 321, 318, 315, 312, 309, 306, 303, 300, 297, 295,
292, 289, 287, 284, 282, 280, 277, 275, 273, 270, 268, 266, 264, 262, 260, 258,
256, 254, 252, 250, 248, 246, 244, 242, 240, 239, 237, 235, 234, 232, 230, 229,
227, 225, 224, 222, 221, 219, 218, 217, 215, 214, 212, 211, 210, 208, 207, 206,
204, 203, 202, 201, 199, 198, 197, 196, 195, 193, 192, 191, 190, 189, 188, 187,
186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171,
170, 169, 168, 168, 167, 166, 165, 164, 163, 163, 162, 161, 160, 159, 159, 158,
157, 156, 156, 155, 154, 153, 153, 152, 151, 151, 150, 149, 148, 148, 147, 146,
146, 145, 144, 144, 143, 143, 142, 141, 141, 140, 140, 139, 138, 138, 137, 137,
136, 135, 135, 134, 134, 133, 133, 132, 132, 131, 131, 130, 130, 129, 129, 128,
128, 127, 127, 126, 126, 125, 125, 124, 124, 123, 123, 122, 122, 121, 121, 120,
120, 120, 119, 119, 118, 118, 117, 117, 117, 116, 116, 115, 115, 114, 114, 114,
113, 113, 112, 112, 112, 111, 111, 111, 110, 110, 109, 109, 109, 108, 108, 108,
107, 107, 107, 106, 106, 106, 105, 105, 105, 104, 104, 104, 103, 103, 103, 102,
102, 102, 101, 101, 101, 100, 100, 100, 99, 99, 99, 98, 98, 98, 98, 97,
97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 94, 93, 93, 93,
93, 92, 92, 92, 92, 91, 91, 91, 91, 90, 90, 90, 90, 89, 89, 89,
89, 88, 88, 88, 88, 87, 87, 87, 87, 86, 86, 86, 86, 86, 85, 85,
85, 85, 84, 84, 84, 84, 84, 83, 83, 83, 83, 82, 82, 82, 82, 82,
81, 81, 81, 81, 81, 80, 80, 80, 80, 80, 79, 79, 79, 79, 79, 78,
78, 78, 78, 78, 78, 77, 77, 77, 77, 77, 76, 76, 76, 76, 76, 76,
75, 75, 75, 75, 75, 74, 74, 74, 74, 74, 74, 73, 73, 73, 73, 73,
73, 72, 72, 72, 72, 72, 72, 72, 71, 71, 71, 71, 71, 71, 70, 70,
70, 70, 70, 70, 70, 69, 69, 69, 69, 69, 69, 68, 68, 68, 68, 68,
68, 68, 67, 67, 67, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66,
66, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64 };

hue -> Pointer to H plane (16-bit) (64 bit aligned)

s -> Pointer to S plane (8-bit) (64 bit aligned)

v -> Pointer to V plane (8-bit) (64 bit aligned)

2.  Now, I want to calculate histogram of "Lightness/Brightness" plane,

So I am using function from IMGLIB,

IMG_histogram_8 ((const unsigned char *)v, in_size, 1, temp_hist, hist);

v -> Input buffer (which is gray value buffer from HSV function)

in_size -> number of pixels (1024*768)

1 -> accumulation

temp_hist[1024] -> I have ensured that buffer is clear before sending it to a function

hist[256] -> output buffer

But the problem is, I am getting error nous output. As my image resolution is (1024*768), total no. of pixel in a frame is 786432.

When I sum up, total no. of pixels in each bin (ie, hist[0].....hist[255]), it shows me 12259457, instead of  786432.

What is wrong with the above logic?

Please guide me on this issue. 

Any help would be highly appreciated.

Thanks,

Krinali Shah

 

  • Hi Krinali,

    One problem I could suspect is that, there is assumption that each histogram bin will have maximum value of 16 bit ( as these pointers (hist, temp_hist) are 16 bit pointers). And your image size is 1024*768, which is more than 16 bits. Hence it is possible that a particular histogram bin value might overflow, and you might get overflowed result. 

    Hence as a solution to this problem, divide image in small chunks of rows, such that maximum pixel in each chunk doesnt cross 32767.  May be here you can choose 1024x31 image chunks to call histogram API in loop, and you can maintain a local 32 bit histogram which you will be accumulating after each call of  "IMG_histogram_8" in loop.

    There is another API for histogram in VLIB also, you can check that also. But this IMGLIB API also should work after making into chunk based call.

    Regards

    Deepak Poddar