converting tiff to image
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Hi all, I am trying to code a tiff format file into a matrix of 2 dimention using imread. then I want to convert back the matrix to my original tiff file using imwrite. but when I do this the new tiff image is not the same as the original one. it is just a black background. is there anyway I can solve this problem?
採用された回答
Image Analyst
2017 年 12 月 22 日
Simply calling
tifImage = imread(inputFilename);
followed by
imwrite(tifImage, outputFilename);
Should not do that. The pixel values should be exactly the same (since no compression is being done). Chances are, you did something to the image, like converted it to a double or something. If you want any more help, attach your code (everything from imread to imwrite and all the lines of code in between) and your original input image that you say is not saving correctly.
7 件のコメント
Image Analyst
2017 年 12 月 22 日
Original post in case he deletes it again.
Hi all, I am trying to code a tiff format file into a matrix of 2 dimention using imread. then I want to convert back the matrix to my original tiff file using imwrite. but when I do this the new tiff image is not the same as the original one. it is just a black background. is there anyway I can solve this problem?
K.G
2017 年 12 月 23 日
I have not written any code for that yet. overall, I want to first have its matrix format and then change the lower half of the elements in the matrix to 1 and then in order to make sure that the picture has changed the same way(the lower half of the image should be black now) I have to convert the modified matrix back to the image to see the changes I applied. I have attached the file here(I could not attach the tiff format but you can make a tiff out of it in the paint app) and I can do the modification to the matrix, but first I need to know how to convert back.
Image Analyst
2017 年 12 月 23 日
K.G. :
"I want to first have its matrix":
tifImage = imread(inputFilename);
"then change the lower half of the elements in the matrix to 1"
[rows, columns, numberOfColorChannels] = size(tifImage);
originalImage = tifImage; % Save original image.
halfRows = round(rows/2);
tifImage(halfRows:end, :, :) = 1;
"to convert the modified matrix back to the image"
tifImage = originalImage;
K.G
2017 年 12 月 23 日
in terms of changing the lower half of the image to pure white it works! however, I also want to have the upper half unchanged and this function turned the upper half to pure black and I do not know why!
Image Analyst
2017 年 12 月 23 日
It depends on the class of your image. I'm assuming it is uint8, so what I did was to set the lower half of the image to 1, almost pure black, not pure white. The only way that 1 would be white is if your image is a double. What that assumes is that values less than 0 are black. Values 1 or more are white. And values in between 0 and 1 are gray scale (like mapped to values between 1 and 254, inclusive).
K.G
2017 年 12 月 23 日
so you mean if I can make a tiff image with double data type from the beginning it will work properly?
Walter Roberson
2017 年 12 月 23 日
"so you mean if I can make a tiff image with double data type from the beginning it will work properly?"
No.
"Hi all, I am trying to code a tiff format file into a matrix of 2 dimention using imread."
Your image is color, which requires 3 or more dimensions. You cannot retain color in 2 dimensions.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Convert Image Type についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
