how to find the matrix of 0's and 1's of the binary image in matlab

7 views (last 30 days)
hello i need a code in matlab and C or C++ and java to upload a binary image and then find its pixel values and write it in the form of matrix of 0's and 1's. Then i need to check every pixel and few of it's neighbors.

Answers (1)

Image Analyst
Image Analyst on 26 May 2013
We can help you with MATLAB code, but usually not with C, C++, or Java. Where do you want to upload this binary image to? You forgot to tell us its destination. Is it some web site? Have you seen urlwrite?
urlwrite(URL,filename) readsWeb content at the specified URL and saves it tothe file specified by filename.
urlwrite(URL,filename,Name,Value)uses additional options specified by one or more Name,Value pairarguments.
Where do you want to write the image to? A file? The command window? A GUI? You forgot to say where you want to write it to.
What does "find its pixel values" and "check every pixel" mean to you? An image is an array of numbers so to "check it" you just give the subscripts, like pixelValue = imageArray(row, column) where row and column are numbers.
  8 Comments
faraz.a
faraz.a on 28 May 2013
for (d)
step 1 read the image(any bit plane image created in (a) 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 on till 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 }
Image Analyst
Image Analyst on 28 May 2013
I'm sorry but I don't have time to translate this into MATLAB for you.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!