Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何按n像素裁剪图像?_Image_Matlab_Crop_Geotiff - Fatal编程技术网

Image 如何按n像素裁剪图像?

Image 如何按n像素裁剪图像?,image,matlab,crop,geotiff,Image,Matlab,Crop,Geotiff,我正在尝试将geotiff图像的各个面修剪500像素(500米)。以下是我到目前为止尝试过的内容,它读取了geotiff并描述了各种geotiff度量,例如边界框的x-min和y-min。我曾尝试使用imcrop(),但在尝试将输出写入geotiff时出错 将geotiff各边修剪500米(或像素)的最佳方法是什么 以下是运行此操作时收到的错误消息: >> clip_raster Starting parallel pool (parpool) using the 'local'

我正在尝试将geotiff图像的各个面修剪500像素(500米)。以下是我到目前为止尝试过的内容,它读取了geotiff并描述了各种geotiff度量,例如边界框的x-min和y-min。我曾尝试使用
imcrop()
,但在尝试将输出写入geotiff时出错

将geotiff各边修剪500米(或像素)的最佳方法是什么



以下是运行此操作时收到的错误消息:

>> clip_raster
Starting parallel pool (parpool) using the 'local' profile ... connected to 8 workers.
Error using geotiffwrite>validateImage (line 383)
Expected input number 2, A, to be nonempty.

Error in geotiffwrite>validateInputs (line 337)
[A, cmap] = validateImage(A, cmap);

Error in geotiffwrite (line 235)
[filename, A, cmap, R, Params] = validateInputs( ...

Error in clip_raster (line 16)
parfor ix = 1:length(fileIndex)         % Note this is the MATLAB parallel processing version of a for loop

为什么imcrop不起作用。正是这样。imcrop应该可以工作,请记住,在写出标题数据时,您需要调整标题数据以使其匹配。@Raab70和Ander Biguri我编辑了这篇文章,以包括我的裁剪实现和错误消息。错误看起来像是在验证图像标题数据期间发生的。完成裁剪后,在写出图像之前,请更新tiffdata.Width、height和bounding box以反映所做的更改。否则它是一个无效的头。您可能还需要更新其他标题属性。请查看上的帮助文档,其中一个示例就是这个问题(最后一个)。注意,他们创建了新的元数据,称之为
R
,新的元数据是
subR
,用于较小的图像,然后再将其写出。
>> clip_raster
Starting parallel pool (parpool) using the 'local' profile ... connected to 8 workers.
Error using geotiffwrite>validateImage (line 383)
Expected input number 2, A, to be nonempty.

Error in geotiffwrite>validateInputs (line 337)
[A, cmap] = validateImage(A, cmap);

Error in geotiffwrite (line 235)
[filename, A, cmap, R, Params] = validateInputs( ...

Error in clip_raster (line 16)
parfor ix = 1:length(fileIndex)         % Note this is the MATLAB parallel processing version of a for loop