Applying a mask I avoid the pixels on the boundary

Discussion in 'Java' started by academic, Feb 15, 2006.

  1. academic

    academic Guest

    I posted this before but it never appeared in my NG.
    Don't know what I did wrong but here it is again.

    Applying a mask I avoid the pixels on the boundary in case the entire image
    is being filtered, so as not to access areas outside the image.

    I'd like to do a better job - for example it the Roi does not include an
    image boundary I should not avoid that boundary of the Roi.

    I been thinking about it and it seems kind of involved.

    Not hard to do but many cases to consider and much code

    Before I do that I wonder if there is a built-in way to simplify the code.


    Thanks in advance for any helpful suggestions
    academic, Feb 15, 2006
    #1
    1. Advertising

  2. academic

    Chris Uppal Guest

    academic wrote:

    > I posted this before but it never appeared in my NG.
    > Don't know what I did wrong but here it is again.


    FWIW, both messages appeared on my server. Some newservers take quite a long
    time between submitting a post and it being available to read (espectially if
    they are having operational difficulties).


    > Applying a mask I avoid the pixels on the boundary in case the entire
    > image is being filtered, so as not to access areas outside the image.
    >
    > I'd like to do a better job - for example it the Roi does not include an
    > image boundary I should not avoid that boundary of the Roi.


    Please don't take this as a criticism, but as an attempt at a helpful
    suggestion. Not many readers will have any idea what you are talking about
    here. Your question is /very/ specific to the way that ImageJ works, and to
    the concepts and APIs that programmers should use when creating plugins. Most
    Java programmers will never have touched ImageJ at all, and won't recognise
    your terms (I've played with it a bit, but not enough to answer your
    question -- sorry). I realise that as a newcomer to Java you will find it hard
    to see where ImageJ stops and Java begins, but that just makes it even more
    important (if you want to get sensible help) that you indicate that your
    question is ImageJ-related (ideally on the subject line).

    Anyway, and FWIW, image processing code usually /is/ long and involved, with
    awkward special cases at/near boundaries. I suspect that you'll just have to
    live with it in this case.

    -- chris
    Chris Uppal, Feb 16, 2006
    #2
    1. Advertising

  3. academic

    academic Guest

    "Chris Uppal" <-THIS.org> wrote in message
    news:43f4562e$0$1175$...
    > academic wrote:
    >
    >> I posted this before but it never appeared in my NG.
    >> Don't know what I did wrong but here it is again.

    >
    > FWIW, both messages appeared on my server. Some newservers take quite a
    > long
    > time between submitting a post and it being available to read (espectially
    > if
    > they are having operational difficulties).


    Still not on mine.

    >
    >
    >> Applying a mask I avoid the pixels on the boundary in case the entire
    >> image is being filtered, so as not to access areas outside the image.
    >>
    >> I'd like to do a better job - for example it the Roi does not include an
    >> image boundary I should not avoid that boundary of the Roi.

    >
    > Please don't take this as a criticism, but as an attempt at a helpful
    > suggestion. Not many readers will have any idea what you are talking
    > about
    > here. Your question is /very/ specific to the way that ImageJ works, and
    > to
    > the concepts and APIs that programmers should use when creating plugins.
    > Most
    > Java programmers will never have touched ImageJ at all, and won't
    > recognise
    > your terms (I've played with it a bit, but not enough to answer your
    > question -- sorry). I realise that as a newcomer to Java you will find it
    > hard
    > to see where ImageJ stops and Java begins, but that just makes it even
    > more
    > important (if you want to get sensible help) that you indicate that your
    > question is ImageJ-related (ideally on the subject line).


    That's an excellent idea. Thanks for taking the time to pass it on

    Thanks again


    >
    > Anyway, and FWIW, image processing code usually /is/ long and involved,
    > with
    > awkward special cases at/near boundaries. I suspect that you'll just have
    > to
    > live with it in this case.


    The thing that bothers is that there are four different image processor so
    I'll have to write similar code four times, maybe differing only in the type
    of the variables.


    >
    > -- chris
    >
    >
    academic, Feb 16, 2006
    #3
  4. academic

    Chris Uppal Guest

    academic wrote:

    > The thing that bothers is that there are four different image processor so
    > I'll have to write similar code four times, maybe differing only in the
    > type of the variables.


    Sounds like a good time to apply some sort of pre-processing. Create a
    template file which contains "almost" Java code and then use any utility you
    are happy with (an editor, Perl, awk, even another Java program) to substitute
    the different types in automatically.

    -- chris
    Chris Uppal, Feb 16, 2006
    #4
  5. academic

    academic Guest

    I just installed Vs2005 which has "code snippets" which I'll bet
    conveniently does just what you suggested. I use it as a java editor and it
    does a nice job.

    Thanks for the suggestion.


    "Chris Uppal" <-THIS.org> wrote in message
    news:43f495d2$1$1169$...
    > academic wrote:
    >
    >> The thing that bothers is that there are four different image processor
    >> so
    >> I'll have to write similar code four times, maybe differing only in the
    >> type of the variables.

    >
    > Sounds like a good time to apply some sort of pre-processing. Create a
    > template file which contains "almost" Java code and then use any utility
    > you
    > are happy with (an editor, Perl, awk, even another Java program) to
    > substitute
    > the different types in automatically.
    >
    > -- chris
    >
    >
    academic, Feb 16, 2006
    #5
  6. academic

    Oliver Wong Guest

    " academic" <> wrote in message
    news:83663$43f4850e$455f9024$...
    >
    > The thing that bothers is that there are four different image processor so
    > I'll have to write similar code four times, maybe differing only in the
    > type of the variables.


    I don't know the exact problem you're trying to solve, so I don't know
    if this will help, but have you considered using generics to only write your
    code once, and supply a different type each time?

    - Oliver
    Oliver Wong, Feb 16, 2006
    #6
  7. academic

    academic Guest

    Sound great. I'll have to look that up.

    I've heard about generics but didn't know java had it.

    Thanks

    "Oliver Wong" <> wrote in message
    news:sY3Jf.1407$Y22.265@clgrps12...
    >" academic" <> wrote in message
    >news:83663$43f4850e$455f9024$...
    >>
    >> The thing that bothers is that there are four different image processor
    >> so I'll have to write similar code four times, maybe differing only in
    >> the type of the variables.

    >
    > I don't know the exact problem you're trying to solve, so I don't know
    > if this will help, but have you considered using generics to only write
    > your code once, and supply a different type each time?
    >
    > - Oliver
    academic, Feb 16, 2006
    #7
  8. academic

    Chris Uppal Guest

    academic wrote:

    > Sound great. I'll have to look that up.
    >
    > I've heard about generics but didn't know java had it.


    It has, but they may not be suitable for your purposes. They don't apply to
    primitive types for one thing (int, byte, float, etc). They also have very
    poor traction with arrays. I don't know exactly what you are doing, but if you
    had code like:

    byte[] data = new int[height * width];
    for (int y = 0; y < height; y++)
    {
    for (x = 0; x < width; x++)
    {
    byte b = data[h*width + y]
    ... etc ..

    and wanted to generalise that to handle arrays of float or int data instead of
    bytes, then Java's generics wouldn't help at all.

    Sad...

    -- chris
    Chris Uppal, Feb 17, 2006
    #8
  9. academic

    academic Guest

    Thanks for the heads up.

    I did it the long way.


    Thanks again


    "Chris Uppal" <-THIS.org> wrote in message
    news:43f5cf02$2$1173$...
    > academic wrote:
    >
    >> Sound great. I'll have to look that up.
    >>
    >> I've heard about generics but didn't know java had it.

    >
    > It has, but they may not be suitable for your purposes. They don't apply
    > to
    > primitive types for one thing (int, byte, float, etc). They also have
    > very
    > poor traction with arrays. I don't know exactly what you are doing, but
    > if you
    > had code like:
    >
    > byte[] data = new int[height * width];
    > for (int y = 0; y < height; y++)
    > {
    > for (x = 0; x < width; x++)
    > {
    > byte b = data[h*width + y]
    > ... etc ..
    >
    > and wanted to generalise that to handle arrays of float or int data
    > instead of
    > bytes, then Java's generics wouldn't help at all.
    >
    > Sad...
    >
    > -- chris
    >
    >
    academic, Feb 17, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexander Malkis
    Replies:
    8
    Views:
    508
    Alexander Malkis
    Apr 14, 2004
  2. Roger23
    Replies:
    2
    Views:
    985
    Roger23
    Oct 12, 2006
  3. Tin Man

    applying edit mask at run time

    Tin Man, Jun 26, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    140
  4. Marcin Tyman

    Conversion mask in hex to bit mask

    Marcin Tyman, May 6, 2008, in forum: Ruby
    Replies:
    4
    Views:
    778
    Robert Klemme
    May 6, 2008
  5. 187
    Replies:
    2
    Views:
    540
    Bart Lateur
    Jul 29, 2004
Loading...

Share This Page