Applying a mask I avoid the pixels on the boundary

A

academic

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
 
C

Chris Uppal

academic said:
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
 
A

academic

Chris Uppal said:
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.
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.
 
C

Chris Uppal

academic said:
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
 
A

academic

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.
 
O

Oliver Wong

academic said:
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
 
A

academic

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

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

Thanks
 
C

Chris Uppal

academic said:
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
 
A

academic

Thanks for the heads up.

I did it the long way.


Thanks again


Chris Uppal said:
academic said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top