c++ - Modify the image pixels using cvGet2D cvSet2D functions -


how can use cvget2d , cvset2d result:

code:

std::string path = "c:\\image.jpg"; cv::mat img = cv::imread (path); cvscalar scal = cvget2d(m, 0, 2); cvset2d(m, 0, 2, new_value);*/ cv::imshow( "result window", img ); 

since know coordinates of top-left , bottom-right rectangle corners:

point tl(250, 250); point br(350, 280); 

you can draw black filled rectangle:

rectangle(img, rect(tl, br), scalar(0,0,0), cv_filled); 

result (note image has different size yours, results appear different):

enter image description here

code:

#include <opencv2\opencv.hpp> using namespace cv;  int main() {     // load image     mat3b img = imread("path_to_image");      // set top-left , bottom-right rectangle points     point tl(250, 250);     point br(350, 280);      // draw filled rect     rectangle(img, rect(tl, br), scalar(0,0,0), cv_filled);      // show result     imshow("result", img);     waitkey();      return 0; } 

note

cvsetxd , cvgetxd old style c syntax. should never mix obsolete c syntax , c++ syntax. if want access pixel values in mat, should use at function.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -