필터 지우기
필터 지우기

How to replace the data in tif file with my own data by matlab?

조회 수: 3 (최근 30일)
Rafat
Rafat 2023년 11월 6일
댓글: Sulaymon Eshkabilov 2023년 11월 7일
Hello,
I have .tif file, how I can replace or edit its data with my own matrix of data?
I cc'd mymatrix and the .tif file.
If you have an idea, please elaborat a littile bit on explanation how to do it, since I am beginner with matlab.
Cheers

채택된 답변

Walter Roberson
Walter Roberson 2023년 11월 6일
편집: Walter Roberson 2023년 11월 6일
The file you have appears to be a GeoTIFF file, which you can read with readgeoraster or the older geotiffread
You can write out the modified data using geotiffwrite
geotiffinfo might also be of interest.
  댓글 수: 4
Rafat
Rafat 2023년 11월 7일
I test it, it's perfect!!
If you please, is this 3 or 2 in the following comand line? I think it's 2?
DS = load(D{1,3}).image_median;
Walter Roberson
Walter Roberson 2023년 11월 7일
편집: Walter Roberson 2023년 11월 7일
The file appears to contain a __MACOSX subdirectory.
pwd
ans = '/users/mss.system.Bh1JYo'
ls -la
total 76 drwxr-xr-x 2 mluser worker 4096 Nov 7 01:53 . drwx------ 1 mluser worker 4096 Nov 7 01:52 .. -rw-r--r-- 1 mluser worker 68764 Nov 7 01:53 Test5.zip
!zipinfo -1 Test5.zip
doy2019190052709_aid0001.tif __MACOSX/._doy2019190052709_aid0001.tif mymatrix.mat __MACOSX/._mymatrix.mat
D=unzip('Test5.zip')
D = 1×4 cell array
{'doy2019190052709_aid0001.tif'} {'__MACOSX/._doy2019190052709_aid0001.tif'} {'mymatrix.mat'} {'__MACOSX/._mymatrix.mat'}
ls -la
total 148 drwxr-xr-x 3 mluser worker 4096 Nov 7 01:53 . drwx------ 1 mluser worker 4096 Nov 7 01:52 .. -rw-r--r-- 1 mluser worker 40220 Jul 19 19:45 doy2019190052709_aid0001.tif drwxr-xr-x 2 mluser worker 4096 Nov 7 01:53 __MACOSX -rw-r--r-- 1 mluser worker 27157 Nov 6 16:00 mymatrix.mat -rw-r--r-- 1 mluser worker 68764 Nov 7 01:53 Test5.zip

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

추가 답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 11월 6일
If understood your question correctly, this is how to get it solved:
D=unzip('Test5.zip');
%%
D1 = imread(D{1,1});
DS = load(D{1,3}).image_median;
subplot(211);imagesc(D1); title('doy2019190052709_aid0001.tif')
subplot(212); imagesc(DS); title('mymatrix.mat')
[X, Y] = find(DS(:,:,1)>0.9);
D1(X,Y,:)=DS(X,Y,:);
%%
figure
imagesc(D1); title('Updated TIFF file')
saveas(gcf, 'UPDATED.tiff') % Save the updated image data
  댓글 수: 5
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 11월 7일
Most welcome. Glad to shed some light :)

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

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by