how can i arrange values from decimal array to the 0-255 range array?

27 views (last 30 days)
0 -0.00198139860960000 -0.00388998355544162 -0.00572886191255736 -0.00750102086941585 -0.00920933176306192 -0.0108565540312587 -0.0124453390781303 -0.0139782340504904 -0.0154576855226614 -0.0168860430881427 -0.0182655628569881 -0.0195984108581946 -0.0208866663468055 -0.0221323250157788 -0.0233373021129890 -0.0245034354640009 -0.0256324884014972 -0.0267261526024528 -0.0277860508343275 -0.0288137396117103 -0.0298107117649778 -0.0307783989226456 -0.0317181739091839 -0.0326313530601456 -0.0335191984565179 -0.0343829200802570 -0.0352236778929990 -0.0360425838399688 -0.0368407037811194 -0.0376190593515460 -0.0383786297532118 -0.0391203534800213 -0.0398451299782557 -0.0405538212443735 -0.0412472533621481 -0.0419262179810936 -0.0425914737380934 -0.0432437476241172 -0.0438837362978709 -0.0445121073481906 -0.0451295005069484 -0.0457365288141988 -0.0463337797372508 -0.0469218162453094 -0.0475011778412852 -0.0480723815523292 -0.0486359228806038 -0.0491922767157594 -0.0497418982105401 -0.0502852236209015 -0.0508226711119786 -0.0513546415311999 -0.0518815191498038 -0.0524036723739695 -0.0529214544267367 -0.0534352040018484 -0.0539452458906113 -0.0544518915828320 -0.0549554398428489 -0.0554561772616449 -0.0559543787859909 -0.0564503082255331 -0.0569442187387094 -0.0574363532983421 -0.0579269451377266 -0.0584162181780033 -0.0589043874375722 -0.0593916594242791 -0.0598782325110765 -0.0603642972958337 -0.0608500369459467 -0.0613356275283716 -0.0618212383256820 -0.0623070321387281 -0.0627931655764496 -0.0632797893333785 -0.0637670484553394 -0.0642550825938419 -0.0647440262496343 -0.0652340090058740 -0.0657251557513461 -0.0662175868941512 -0.0667114185662600 -0.0672067628193199 -0.0677037278120833 -0.0682024179898092 -0.0687029342559796 -0.0692053741366542 -0.0697098319377766 -0.0702163988957317 -0.0707251633214386 -0.0712362107382581 -0.0717496240139748 -0.0722654834871086 -0.0727838670877977 -0.0733048504534846 -0.0738285070396278 -0.0743549082256536 -0.0748841234163502 -0.0754162201389020 -0.0759512641357502 -0.0764893194534597 -0.0770304485277654 -0.0775747122649607 -0.0781221701197887 -0.0786728801699849 -0.0792268991876176 -0.0797842827073651 -0.0803450850918607 -0.0809093595942348 -0.0814771584179744 -0.0820485327742172 -0.0826235329365919 -0.0832022082937114 -0.0837846073994218 -0.0843707780209037 -0.0849607671847215 -0.0855546212209092 -0.0861523858051785 -0.0867541059993321 -0.0873598262899607 -0.0879695906254989 -0.0885834424517117 -0.0892014247456812 -0.0898235800483597 -0.0904499504957513 -0.0910805778487833 -0.0917155035219255 -0.0923547686106114 -0.0929984139175164 -0.0936464799777410 -0.0942990070829501 -0.0949560353045130 -0.0956176045156893 -0.0962837544129028 -0.0969545245361444 -0.0976299542885422 -0.0983100829551371 -0.0989949497208981 -0.0996845936880122 -0.100379053892482 -0.101078369320058 -0.101782578921548 -0.102491721627507 -0.103205836362368 -0.103924962058010 -0.104649137666808 -0.105378402174176 -0.106112794610634 -0.106852354063420 -0.107597119687663 -0.108347130717138 -0.109102426474631 -0.109863046381918 -0.110629029969387 -0.111400416885312 -0.112177246904804 -0.112959559938443 -0.113747396040613 -0.114540795417553 -0.115339798435137 -0.116144445626396 -0.116954777698787 -0.117770835541240 -0.118592660230970 -0.119420293040078 -0.120253775441957 -0.121093149117498 -0.121938455961114 -0.122789738086590 -0.123647037832768 -0.124510397769073 -0.125379860700889 -0.126255469674797 -0.127137267983666 -0.128025299171633 -0.128919607038945 -0.129820235646693 -0.130727229321440 -0.131640632659734 -0.132560490532537 -0.133486848089546 -0.134419750763438 -0.135359244274025 -0.136305374632332 -0.137258188144605 -0.138217731416237 -0.139184051355645 -0.140157195178068 -0.141137210409321 -0.142124144889482 -0.143118046776535 -0.144118964549963 -0.145126947014293 -0.146142043302602 -0.147164302879984 -0.148193775546975 -0.149230511442952 -0.150274561049491 -0.151325975193704 -0.152384805051543 -0.153451102151086 -0.154524918375791 -0.155606305967737 -0.156695317530843 -0.157792006034073 -0.158896424814619 -0.160008627581079 -0.161128668416616 -0.162256601782113 -0.163392482519316 -0.164536365853966 -0.165688307398934 -0.166848363157341 -0.168016589525684 -0.169193043296953 -0.170377781663753 -0.171570862221418 -0.172772342971132 -0.173982282323055 -0.175200739099446 -0.176427772537788 -0.177663442293932 -0.178907808445229 -0.180160931493682 -0.181422872369101 -0.182693692432265 -0.183973453478096 -0.185262217738840 -0.186560047887264 -0.187867007039858 -0.189183158760052 -0.190508567061448 -0.191843296411058 -0.193187411732565 -0.194540978409595 -0.195904062288997 -0.197276729684152 -0.198659047378283 -0.200051082627797 -0.201452903165631 -0.202864577204624 -0.204286173440901 -0.205717761057281 -0.207159409726700 -0.208611189615655 -0.210073171387666 -0.211545426206761 -0.213028025740980 -0.214521042165900 -0.216024548168178 -0.217538616949124 -0.219063322228288 -0.220598738247072 -0.222144939772364

Answers (2)

Image Analyst
Image Analyst on 3 Jan 2016
There is a function to do this. It's called mat2gray. Just call it with your numbers, to get it into the range 0-1, then multiply by 255 to get it into the range 0-255. Then cast to uint8 with the uint8() function if you want it to be a uint8 image.
numbersUint8 = uint8(255 * mat2gray(yourNumbers));

Andrei Bobrov
Andrei Bobrov on 3 Jan 2016
z =[0
-0.00198139860960000
-0.00388998355544162
-0.00572886191255736
-0.00750102086941585
-0.00920933176306192
-0.0108565540312587
-0.0124453390781303
-0.0139782340504904
-0.0154576855226614
-0.0168860430881427
-0.0182655628569881
-0.0195984108581946
-0.0208866663468055
-0.0221323250157788
-0.0233373021129890
-0.0245034354640009
-0.0256324884014972
-0.0267261526024528
-0.0277860508343275
-0.0288137396117103
-0.0298107117649778
-0.0307783989226456
-0.0317181739091839
-0.0326313530601456
-0.0335191984565179
-0.0343829200802570
-0.0352236778929990
-0.0360425838399688
-0.0368407037811194
-0.0376190593515460
-0.0383786297532118
-0.0391203534800213
-0.0398451299782557
-0.0405538212443735
-0.0412472533621481
-0.0419262179810936
-0.0425914737380934
-0.0432437476241172
-0.0438837362978709
-0.0445121073481906
-0.0451295005069484
-0.0457365288141988
-0.0463337797372508
-0.0469218162453094
-0.0475011778412852
-0.0480723815523292
-0.0486359228806038
-0.0491922767157594
-0.0497418982105401
-0.0502852236209015
-0.0508226711119786
-0.0513546415311999
-0.0518815191498038
-0.0524036723739695
-0.0529214544267367
-0.0534352040018484
-0.0539452458906113
-0.0544518915828320
-0.0549554398428489
-0.0554561772616449
-0.0559543787859909
-0.0564503082255331
-0.0569442187387094
-0.0574363532983421
-0.0579269451377266
-0.0584162181780033
-0.0589043874375722
-0.0593916594242791
-0.0598782325110765
-0.0603642972958337
-0.0608500369459467
-0.0613356275283716
-0.0618212383256820
-0.0623070321387281
-0.0627931655764496
-0.0632797893333785
-0.0637670484553394
-0.0642550825938419
-0.0647440262496343
-0.0652340090058740
-0.0657251557513461
-0.0662175868941512
-0.0667114185662600
-0.0672067628193199
-0.0677037278120833
-0.0682024179898092
-0.0687029342559796
-0.0692053741366542
-0.0697098319377766
-0.0702163988957317
-0.0707251633214386
-0.0712362107382581
-0.0717496240139748
-0.0722654834871086
-0.0727838670877977
-0.0733048504534846
-0.0738285070396278
-0.0743549082256536
-0.0748841234163502
-0.0754162201389020
-0.0759512641357502
-0.0764893194534597
-0.0770304485277654
-0.0775747122649607
-0.0781221701197887
-0.0786728801699849
-0.0792268991876176
-0.0797842827073651
-0.0803450850918607
-0.0809093595942348
-0.0814771584179744
-0.0820485327742172
-0.0826235329365919
-0.0832022082937114
-0.0837846073994218
-0.0843707780209037
-0.0849607671847215
-0.0855546212209092
-0.0861523858051785
-0.0867541059993321
-0.0873598262899607
-0.0879695906254989
-0.0885834424517117
-0.0892014247456812
-0.0898235800483597
-0.0904499504957513
-0.0910805778487833
-0.0917155035219255
-0.0923547686106114
-0.0929984139175164
-0.0936464799777410
-0.0942990070829501
-0.0949560353045130
-0.0956176045156893
-0.0962837544129028
-0.0969545245361444
-0.0976299542885422
-0.0983100829551371
-0.0989949497208981
-0.0996845936880122
-0.100379053892482
-0.101078369320058
-0.101782578921548
-0.102491721627507
-0.103205836362368
-0.103924962058010
-0.104649137666808
-0.105378402174176
-0.106112794610634
-0.106852354063420
-0.107597119687663
-0.108347130717138
-0.109102426474631
-0.109863046381918
-0.110629029969387
-0.111400416885312
-0.112177246904804
-0.112959559938443
-0.113747396040613
-0.114540795417553
-0.115339798435137
-0.116144445626396
-0.116954777698787
-0.117770835541240
-0.118592660230970
-0.119420293040078
-0.120253775441957
-0.121093149117498
-0.121938455961114
-0.122789738086590
-0.123647037832768
-0.124510397769073
-0.125379860700889
-0.126255469674797
-0.127137267983666
-0.128025299171633
-0.128919607038945
-0.129820235646693
-0.130727229321440
-0.131640632659734
-0.132560490532537
-0.133486848089546
-0.134419750763438
-0.135359244274025
-0.136305374632332
-0.137258188144605
-0.138217731416237
-0.139184051355645
-0.140157195178068
-0.141137210409321
-0.142124144889482
-0.143118046776535
-0.144118964549963
-0.145126947014293
-0.146142043302602
-0.147164302879984
-0.148193775546975
-0.149230511442952
-0.150274561049491
-0.151325975193704
-0.152384805051543
-0.153451102151086
-0.154524918375791
-0.155606305967737
-0.156695317530843
-0.157792006034073
-0.158896424814619
-0.160008627581079
-0.161128668416616
-0.162256601782113
-0.163392482519316
-0.164536365853966
-0.165688307398934
-0.166848363157341
-0.168016589525684
-0.169193043296953
-0.170377781663753
-0.171570862221418
-0.172772342971132
-0.173982282323055
-0.175200739099446
-0.176427772537788
-0.177663442293932
-0.178907808445229
-0.180160931493682
-0.181422872369101
-0.182693692432265
-0.183973453478096
-0.185262217738840
-0.186560047887264
-0.187867007039858
-0.189183158760052
-0.190508567061448
-0.191843296411058
-0.193187411732565
-0.194540978409595
-0.195904062288997
-0.197276729684152
-0.198659047378283
-0.200051082627797
-0.201452903165631
-0.202864577204624
-0.204286173440901
-0.205717761057281
-0.207159409726700
-0.208611189615655
-0.210073171387666
-0.211545426206761
-0.213028025740980
-0.214521042165900
-0.216024548168178
-0.217538616949124
-0.219063322228288
-0.220598738247072
-0.222144939772364];
mn = min(z);
out = 255/(max(z)-mn)*(z - mn);

Community Treasure Hunt

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

Start Hunting!