且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在R中裁剪图像

更新时间:2022-02-14 06:50:34

我不知道R,但是如果我使用等效的imagemagick命令,则您的印章将被裁剪,图像的下半部分将被裁剪.切碎的底部的左上角.你为什么要用排骨?同样,在裁剪之后,如果将图像保存到PNG或TIFF,则图像上还会保留虚拟画布,应使用+ repage删除该画布.不确定R中的内容,但可能是+ 0 + 0.如果要裁剪左上角,只需使用-gravity northwest并以所需的尺寸WxH + 0 + 0进行裁剪,除非您希望将偏移量替换为+ 0 + 0

I do not know R, but if I use the equivalent imagemagick commands, your chop is cropping approximately, the bottom half of the image and the subsequent crop is cropping the top left corner of the chopped bottom part. Why are you using chop? Also after a crop, the image will have a virtual canvas left if you save to PNG or TIFF that should be removed by using +repage. Not sure what that is in R, but may be repage +0+0. If you want to crop the top left corner, just use -gravity northwest and crop with the size you want WxH+0+0, unless you want an offset in place of +0+0

convert Chrometab.jpg -chop 0x185+190 +write tmp1.png -crop 50x55+1 tmp2.png

tmp1.png

tmp2.png

位置:

convert Chrometab.jpg -gravity northwest -crop 50x55+1+0 +repage tmp3.png

tmp3.png