cv::Mat Argmax(const boost::shared_ptr<caffe::Blob<float> >& probLayer){
unsigned int w_max = probLayer->width();
unsigned int h_max = probLayer->height();
unsigned int c_max = probLayer->channels();
float* data = (float*)probLayer->cpu_data();
cv::Mat classes(cv::Size(w_max, h_max),CV_8U);
classes.setTo(0);
int plan_size = w_max*h_max;
for (int y = 0; y < h_max; y++) {
uchar* optr = classes.ptr<uchar>(y);
int yoffset = y*w_max;
for (int x = 0; x < w_max; x++) {
int xoffset = yoffset+x;
int max_label=0;
float max_proba=0.f;
for(int c = 0; c < c_max; c++){
int offset = c*plan_size + xoffset;
float proba = data[offset];
if( max_proba < proba ){
max_label = c;
max_proba = proba;
}
}
*optr++ = max_label;
}
}
return classes;
}--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/e0b4a4ec-e7e0-4b28-b9ed-b429482b0e6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/3e129564-63ec-43f8-9fd6-05e71d5cb5ac%40googlegroups.com.