PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 27, 2022

[FIXED] How to crop image's borders opencv

 July 27, 2022     c++, crop, opencv     No comments   

Issue

I have an image with size 640x400 and i need to crop the defined borders, so 5 px from each side. So, the end image will 630x390 and without the borders. What is the easiest way to do in with openCV in c++.


Solution

Simple:

int padding = 5;
cv::Mat crop = cv::Mat(img, cv::Rect(padding, padding, img.cols - 2 * padding, img.rows - 2 * padding));


Answered By - Nuzhny
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing