필터 지우기
필터 지우기

Problems using geotiffwrite with colormap

조회 수: 6 (최근 30일)
Amit Kallush
Amit Kallush 2023년 2월 14일
댓글: Amit Kallush 2023년 2월 20일
I have a .png file and his associated .wld file. I’m using “imread” and “worldfileread” to load both files into Matlab and write them back in tif format.
It’s working great, but the file is saved without a color map. So I tried to load the original color map and save it together, but for some reason, I get the error:
Error using geotiffwrite
Function GEOTIFFWRITE expected its third input argument CMAP to be a valid colormap. Valid colormaps must be nonempty, double, 2-D matrices with 3 columns.
As far as I can see, the cmap is a double, 2-D matrix with 3 columns.
Maybe somebody has a solution for that?
The files and script are attached.
Thanks!
[image,cmap] = imread('ABX_N0Q_202109290033.png');
R = worldfileread('ABX_N0Q_202109290033.wld',"geographic",size(image));
geotiffwrite('test.tif', image, R,cmap);

채택된 답변

Yuvraj Singh
Yuvraj Singh 2023년 2월 20일
Hi Amit,
geotiffwrite('test.tif', image, R,cmap);
'geotiffwrite' expects its third argument to be cmap, in the code mentioned above cmap is the fourth argument.
Refer to the below documentation for the right syntax.
  댓글 수: 1
Amit Kallush
Amit Kallush 2023년 2월 20일
Thanks that was really helpful! I didnt realise that it should come as the third value. now its working
Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by