How to convert grayscale image to binary and reverse?

4 ビュー (過去 30 日間)
John Applesheet
John Applesheet 2016 年 11 月 18 日
コメント済み: Image Analyst 2016 年 11 月 18 日
I have a task to convert a grayscale image to binary and then take it back to its original form. I tried doing the former part by using im2bw function but was unable to do the latter after that as I had killed all the 'other than black and white patterns' when converting to binary. Any suggestions? :D
Also, I don't know what the function mat2gray is for, since the input image (grayscale for instance) has itself already been a matrix hasn't it?
Thanks and sorry for my bad English.

採用された回答

Image Analyst
Image Analyst 2016 年 11 月 18 日
Once you threshold an image with im2bw() to produce a logical (binary) image, you can't then take just that image and get back your gray scale image because you don't have enough information. Therefore you should save/keep your original gray scale image. Of course if you still have the original, then you're all set.
mat2gray() is a function that takes an array in any range at all, and scales it so the min is at 0, then max if at 1, and everything else is scaled linearly between 0 and 1.
  2 件のコメント
John Applesheet
John Applesheet 2016 年 11 月 18 日
編集済み: John Applesheet 2016 年 11 月 18 日
Thx, so that means there's no way to turn it back (from binary) to the intact one then ?
Coincidentally, i saw your answers on several related topics while surfing the net, about 3-4 years ago lol. Those were helpful for me xD
Image Analyst
Image Analyst 2016 年 11 月 18 日
Correct. Like I said, there is no way unless you save the original.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by