Image looks open exposed while using imwrite on opencv
I am trying to save 16 bit images from ROS bag as .jpg, but where i save them, my images look over exposed, but when I use matlab its saved correctly. I'm not sure where I am screwing things up. My function is shown below.
void img_listener::callbackirimage(const sensor_msgs::Image::ConstPtr& msg)
{
ir_img_ptr=cv_bridge::toCvCopy(msg,msg->encoding);
rep_ros_ir_time[ir_image_count] = msg->header.stamp.toSec();
#ifdef _DEBUG
ROS_INFO("The reported color image time :%15.15f",rep_ros_clr_time[color_image_count]);
#endif
//ir_img_ptr->image.convertTo(ir_img[ir_image_count],CV_8UC1,(double)(1.0/256),256);
//ir_img_ptr->image.convertTo(ir_img[ir_image_count],CV_8UC1);
ir_img[ir_image_count] = ir_img_ptr->image;
if (ir_image_count >= FRAME_RATE_COLOR_IMG)
ir_image_count=0;
else
ir_image_count++;
}
where
cv::Mat ir_img[FRAME_RATE_COLOR_IMG];
When I perform a imshow or a imwrite, the resultant image looks over exposed .
as compared to
Setup: Ubuntu, ros jade, opencv 2.4.8. Any Help is greatly Appreciated.
Thanks Akshay