Results 1 to 5 of 5

Math Help - MATLAB: n00b question on graphics

  1. #1
    Newbie
    Joined
    Jan 2008
    Posts
    5

    MATLAB: n00b question on graphics

    Hi there, as part of a project, I have been asked to create a binary image in MATLAB using a 20x20 matrix.

    I have made a matrix so that there is a letter 'H' showing. When it comes to printing this I use the only function that I have found that should work which is image(A) where A is the matrix. This just ends up giving a picture which is covered in black from axis 0-20 on y and x.

    Is there a way to print this picture at all. The matrix is:

    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

    Sorry if this seems extremely elementary but I am a beginner with MATLAB

    Thanks in advance. Chris
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by reakon View Post
    Hi there, as part of a project, I have been asked to create a binary image in MATLAB using a 20x20 matrix.

    I have made a matrix so that there is a letter 'H' showing. When it comes to printing this I use the only function that I have found that should work which is image(A) where A is the matrix. This just ends up giving a picture which is covered in black from axis 0-20 on y and x.

    Is there a way to print this picture at all. The matrix is:

    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

    Sorry if this seems extremely elementary but I am a beginner with MATLAB

    Thanks in advance. Chris
    The image function when given an array uses the values to index into the colour map, which goes from 1 to whatever the length of the colour map is.

    So at the very least add 1 to each entry, and better yet find the size of the colour map and use two distant values to code your binary image.

    Other wise tyoe "help image" and see what it says for other options.

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jan 2008
    Posts
    5
    Thanks for your help but I found another way of showing an image which was using the mesh(A) tool and letting the pixels that were part of an image to be 100 and the rest 0. I was then able to apply a noise matrix of size 20 and use SVD to enhance the image which is exactly what the project wanted.

    Thanks again, Chris
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Senior Member Peritus's Avatar
    Joined
    Nov 2007
    Posts
    397
    no need to enhance anything just use imshow()
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Lord of certain Rings
    Isomorphism's Avatar
    Joined
    Dec 2007
    From
    IISc, Bangalore
    Posts
    1,465
    Thanks
    6
    Quote Originally Posted by Peritus View Post
    no need to enhance anything just use imshow()
    imshow(logical(matrix)) will definitely work, but will just imshow work?
    (Am on Linux box, lazy to boot windows and check)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Help with graphics.
    Posted in the Algebra Forum
    Replies: 1
    Last Post: December 20th 2011, 10:57 AM
  2. Graphics
    Posted in the Trigonometry Forum
    Replies: 0
    Last Post: November 9th 2009, 07:25 AM
  3. Maple Graphics
    Posted in the Math Software Forum
    Replies: 12
    Last Post: July 31st 2009, 07:22 PM
  4. n00b Testing Latex
    Posted in the LaTeX Help Forum
    Replies: 1
    Last Post: June 28th 2009, 01:19 PM
  5. My graphics
    Posted in the LaTeX Help Forum
    Replies: 1
    Last Post: December 29th 2006, 02:03 AM

Search Tags


/mathhelpforum @mathhelpforum