how to unified the get back Mat.at<..> function ?

asked 2016-11-05 16:08:59 -0600

azdoud.y gravatar image

hello opencv community, in my code i'm dealing with mutiple Matrices type or depth Mat, is it possible to use Mat.at function without having any information about its type,

any help i would be glad

best regards

curr_pixel_value = frame.at<float>(row_index,clo_index);
curr_pixel_value = frame.at<uchar>(row_index,clo_index);
curr_pixel_value = frame.at<double>(row_index,clo_index);
edit retag flag offensive close merge delete

Comments

what is your actual use-case for this ?

the short answer might be:

  1. you should not write per-pixel loops at all. (most likely, you're re-inventing the wheel, while there's something high-level already implemented)
  2. not knowing the type when writing the code is an absolutely rare situation.
berak gravatar imageberak ( 2016-11-05 20:49:14 -0600 )edit

I'm using this to applying an arithmetic equation inside a ROI so I see my case is rare, I'll avoid that next time thank you Sir #berak :)

azdoud.y gravatar imageazdoud.y ( 2016-11-06 02:30:21 -0600 )edit

again, what is your "arithmetic equation", and where does the input for it come from ?

berak gravatar imageberak ( 2016-11-06 02:33:17 -0600 )edit
1

i'm trying to calculate the distribution of Gibbs (Gibbs random field) for this ROI

azdoud.y gravatar imageazdoud.y ( 2016-11-06 02:52:37 -0600 )edit

please show us, what you're doing. (we can't help without context)

berak gravatar imageberak ( 2016-11-06 03:00:59 -0600 )edit

you will find the equation on this links 1- https://postimg.org/image/ahtl2mx1v/ 2- https://postimg.org/image/woygx23cp/

azdoud.y gravatar imageazdoud.y ( 2016-11-06 03:23:12 -0600 )edit
1

this is not, what you are doing.

(and btw, you can do exp & sum on whole Mat's / rois, no need for random access.)

berak gravatar imageberak ( 2016-11-06 03:43:01 -0600 )edit

thank you for your hospitality Sir

azdoud.y gravatar imageazdoud.y ( 2016-11-06 04:06:36 -0600 )edit