필터 지우기
필터 지우기

Array divided by 255 gives me 0

조회 수: 4 (최근 30일)
Thomas Koelen
Thomas Koelen 2015년 4월 7일
댓글: James Tursa 2015년 4월 7일
I have an matrix that looks like this (but bigger)
[30 29 31;
29 30 30;
30 31 30]
now when I divide it by 255, it gives me this:
[0 0 0;
0 0 0;
0 0 0]
As far as I know I never changed anything with digits, does anyone have an idea what's going on?
Kind regards
edit: the matrix contains doubles

답변 (2개)

Joep
Joep 2015년 4월 7일
편집: Joep 2015년 4월 7일
This is because you matrix was written in uint8. You should first convert it to double.
double([30 29 31; 29 30 30; 30 31 30])
It's not clear why it is in uint8 maybe you load some image or create uint8 matrix.
PS: uint8 means you got a 8 bit number so 2^8=256 which will give 0->255. If you need some help I can help you also in dutch.
  댓글 수: 2
Thomas Koelen
Thomas Koelen 2015년 4월 7일
I already converted it to double, I just didn't show it on the post. It didn't work, then I reopened Matlab and it did work. I don't know what was wrong, guess I'll never know :P
James Tursa
James Tursa 2015년 4월 7일
Most likely you thought you had converted it to double, but hadn't. Then you restarted MATLAB and wiped out the evidence.

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


Ilham Hardy
Ilham Hardy 2015년 4월 7일
testmat = [30 29 31; 29 30 30; 30 31 30] ;
testmat =
30 29 31
29 30 30
30 31 30
>> testmatdev = testmat./255
testmatdev =
0.1176 0.1137 0.1216
0.1137 0.1176 0.1176
0.1176 0.1216 0.1176
  댓글 수: 1
Thomas Koelen
Thomas Koelen 2015년 4월 7일
It's not working either, ran my code on another pc and it's working just fine. After reopening Matlab on my own computer it's also running fine.
Thanks though!

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by