필터 지우기
필터 지우기

Binary representation of ASCII values

조회 수: 1 (최근 30일)
kartheek
kartheek 2013년 9월 8일
I have an image of size mXn and I want to generate the 8-bit representation of ASCII value of character/pixel and want to insert that into an array. how to proceed?

답변 (2개)

Walter Roberson
Walter Roberson 2013년 9월 8일
dec2bin(Value, 8) - '0'
  댓글 수: 2
kartheek
kartheek 2013년 9월 8일
This converts a decimal number to binary. but i want the ascii code of the the decimal in binary 8 bit form
Walter Roberson
Walter Roberson 2013년 9월 8일
dec2bin(Value + '0', 8) - '0'
provided that all the entries are single digit, and that you are not wanting to put in any spaces.
If the entries might be multi-digit, then are they always the same number of digits? If not then how do you want the empty locations indicated? As if they had printable 0's at the front? Or do you want the binary of a space character inserted? Should the empty-location processing be consistent per-row, per-column, or over the whole array ?

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


Image Analyst
Image Analyst 2013년 9월 8일
We don't know what you mean. Your pixel's 8 bit values are already IN binary since it's digitized in the computer. So the only other way is to show it as a string, as Walter showed you. Since you didn't like that, I don't know what you want. Perhaps you want im2html: http://www.mathworks.com/matlabcentral/fileexchange/32273-im2html-m
  댓글 수: 2
kartheek
kartheek 2013년 9월 8일
this is not i wanted. suppose i have an image array [1 2 3 4]. now, i want a function to convert its every element into the binary representation of their ascii values. i mean, the ascii representation of 1 is 49. i want a function that converts 1 to its binary 8 bit representation i.e., 00110001
Image Analyst
Image Analyst 2013년 9월 8일
That's precisely what Walter showed. Something like you showed HAS to be a string. If it were a number, say an integer, then 00110001 would really be 110,001 (one hundred ten thousand and one). I doubt that's what you want - if it is, explain why, because I see no use for that (turning 1 into 110,001, and turning 2 into 110,010, etc.) - I mean, they would not even be consecutive numbers anymore. What sense would that make???

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

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by