Eliminating the Border Around a Generated Image

16 views (last 30 days)
Sarah on 27 Aug 2018
Commented: Sarah on 27 Aug 2018
I am creating images using the rectangle() function with various line and space sizes. I attached an example image to this question. I want to eliminate the border of white that surrounds the black rectangles. (It affects my pixel count calculations.) Currently, I am just using the imcrop() function, but the cropping dimensions have to change according to the line and space sizes. Is there a more efficient way than imcrop()?

Accepted Answer

jonas on 27 Aug 2018
Edited: jonas on 27 Aug 2018
There is a function that will do this for you in one step, but I forgot what it's called. Here's a primitive solution for you!
Basically you find the upper left and bottom right corners, and then crop a rectangle between those.
Sarah on 27 Aug 2018
Excellent, thank you. Now it all works well.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!