After division i am getting 1 as the answer
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Udit Jain
il 17 Set 2017
Commentato: Udit Jain
il 17 Set 2017
editor:
f1=input('Enter a image name:','s');
a1=imread(f1);
c1=rgb2gray(imresize(a1,[3,9]))';
N=[208 16 235 255 44 229 236 34 247;...
245 21 213 254 55 252 215 51 249;...
248 22 225 252 30 240 242 27 244]';
N=N/256
c2=c1/256
Command window: Enter a image name:51.jpg
N =
0.8125 0.9570 0.9688
0.0625 0.0820 0.0859
0.9180 0.8320 0.8789
0.9961 0.9922 0.9844
0.1719 0.2148 0.1172
0.8945 0.9844 0.9375
0.9219 0.8398 0.9453
0.1328 0.1992 0.1055
0.9648 0.9727 0.9531
c2 =
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
>>
1 Commento
Jan
il 17 Set 2017
I've marked the code with the mouse and pressed the "{} Code" button to make the code readable. Please do this by your own in the future. Thanks.
Risposta accettata
Image Analyst
il 17 Set 2017
Cast c1 to double so that you're not doing an integer divide, but doing a floating point divide instead:
c2 = double(c1) / 256;
Più risposte (1)
Jan
il 17 Set 2017
Modificato: Jan
il 17 Set 2017
What is your question? Does the result differ from your expectation? Then explain, what you expect instead, because the readers cannot guess this detail. Of course the code does exactly what it should.
a1 = imread(f1);
a2 = imresize(a1, [3,9]);
c1 = rgb2gray(a2)';
Check the contents of the variables:
class(a1)
class(a1)
class(c1)
a1(1, 1, :)
a2(1, 1, :)
c1(1)
c1(1) / 256
What do you see?
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!