centerobject(bw)
For a lot of shape descriptors (e.g. Fourier descriptors, Zernike Moments etc.) in image feature generation it is necessary to have the objected centered to the image center. Meaning that the center of mass of the object lies in the middle of the image.
Because i couldn't find any similar function to center objects in images i wrote this little function for myself. With this submission i hope i can save some of your working time to figure out a similar script.
The function does extend the image in case that the translation needed to put the object to the image center does not fit withhin the image boundarys.
CM = CENTERMASK(BW) needs and MxN logical image as input with only one object present and returns and RxR logical image with the object centered to the middle of the image.
Due to numerical reasons there can be a shift of maximum +- 0.5.
The function is tested with the MPEG-7 Dataset and worked for all images perfectly. The above image is one of the results.
Look at the centerobject_example file to see how the function works and what it needs as input etc.
If you have any suggestions or questions, feel free to write a comment.
(I wrote this function with Matlab 8.1 (R2013a) but i am pretty sure it will work with older releases)
引用格式
Frederik Kratzert (2024). centerobject(bw) (https://www.mathworks.com/matlabcentral/fileexchange/52560-centerobject-bw), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0.0 |