write this code in matlab
1 view (last 30 days)
Show older comments
step 1 read the image
then write it in a 2-d array(matrix)
assign i=1 and j=1 (1=rows, j= columns)
assign A(i,j)=X (this is array)
A(i,j-1)=A
A(i-1,j)=B
now give context=AB (which should be 00,01,10,11 any one of them)
if {
context=00
{
if
X=0
{ c0(00)=1+c0(00) }
else if X=1
{ c1(00)=1+c1(00) (at start c1(00) c0(00) all are equal to zero) }
cont(00)=1+cont(00)
}
else if context=01
{ if x= 0
{
c0(01)=1+c0(01)
}
else if X=1
{
c1(01)=1+c1(01)
}
cont(01)=1+cont(01)
}
else if context=10
{
if X=0
{
c0(10)=1+c0(10)
} else if X=1
{
c1(10)=1+c1(10)
}
cont(10)=1+cont(10)
}
else if context=11
{
if X=0 { c0(11)=1+c0(11)
}
else if X=1
{
c1(11)=1+c(11)
}
cont(11)=1+cont(11)
}
if j<256 (size of the image is 256*256 then we should take 256)
{
j=j+1
}
else if j=256
{ i=i+1
} if i=256 && j=256 (both should 256)
end
else go to
{
assign A(i,j)=X (it should go back to this)
} then i have to find out some float values when displaying this it should c0me steady state probabilities p(00)=cont(00)/(total number of counts i think it will be the size of the matrix 256*256)
p(01)=cont(01)/(256*256)
p(10)=count(10)/(256*256)
p(11)=count(11)/(256*256) }
now display these all the below conditional probabilities p0(00)=c0(00)/cont(00)
p1(00)=c1(00)/cont(00)
p0(01)=c0(01)/cont(01)
p1(01)=c1(01)/cont(01)
p0(10)=c0(10)/cont(10)
p1(10)=c1(10)/cont(10)
p0(11)=c0(11)/cont(11)
p1(11)=c1(11)/cont(11)
similarly all the values then h(00)=p0(00)logbase2(1/p0(00)) +p1(00)logebase2(1/(p1(00)
h(01)=p0(01)logbase2(1/p0(01)) +p1(01)logebase2(1/(p1(01)
so onll ti h(11) can we write h(00)= h(AB)?? these 00,01,10,11 are actually AB it is very hard how to write all and display all these assign h(s) entropy= p(AB)H(AB) end the way i wrote in my notes p(00)h(00)+p(01)h(01)+p(10)h(10)+p(11)h(11) display all these values }
3 Comments
Jan
on 28 May 2013
Do you have a specific question or do you assume that we solve the complete problem for you?
Answers (1)
Image Analyst
on 28 May 2013
Indexes have to be integers like 1, 2, 3, etc. (or logical true/false) - you can't have an index of 00. You'll have to figure that out. And, MATLAB code doesn't use { to start a block, and it uses "end" instead of } to finish a block. Comments begin with a % symbol. I, for one, don't have time to fix your code or translate it into MATLAB code for you. Good luck.
6 Comments
See Also
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!