drphilmarshall / Lens-Zoo

Apache License 2.0
0 stars 0 forks source link

Error reading mask (alpha channel) images #51

Closed drphilmarshall closed 10 years ago

drphilmarshall commented 10 years ago

Currently, when a sim is marked, @isLensMarked is assigned the value "0", no matter where you click. It's as if the alpha channel mask was missing...

For now, I've implemented the following hack: any click in a sim image is interpreted as a successful lens identification, with corresponding congratulatory feedback message. This will at least allow the SWAP agents to be trained, but represents quite a low resolution system.

I'd like to assign this to @jgeach but I can't add him as a collaborator - but I'll pass the issue along to him to see if there's something up with the alpha channel images.

drphilmarshall commented 10 years ago

OK, I checked the PNGs and they do have alpha images with value 255 where there is no arc, and 254 where there is. This is the inverse of the CFHTLS scheme, so I switched the values in the code, ready for the time when we fix the real problem, which is that the mask/alpha image is not being read correctly. Here's the code:

checkImageMask: (x, y) =>
  try
    pixel = @ctx.getImageData(x, y, 1, 1)
    mask = pixel.data[3]
  catch err
    mask = 0
  return if mask is 254 then true else mask

Any annotation made on a sim image leads to a value 0 from this function, so the getImageData call is throwing an error of some kind. Any ideas what is going wrong, @edpaget ? Something non-standard about the PNGs? Can you see any fixes?

drphilmarshall commented 10 years ago

One thought I had: the coordinates might be messed up between the image and the canvas. The images are 199x199 pixels, but they are being displayed on a 441x441 pixel box. I don't see this being accounted for in the code. HOWEVER, this is not the problem with the mask checking - I tried placing a marker in the corner, to get x and y values less than 199, and that too led to a mask = 0 error.

anupreeta27 commented 10 years ago

@drphilmarshall what's the convention for the y-axis? my catalogs had y-axis with increasing values downwards.

drphilmarshall commented 10 years ago

Hold that thought - it might be an issue later, but for now I think its something else: every call to ctx.getImageData(x,y,1,1) is returning an error.

On Mon, Jan 6, 2014 at 4:37 AM, anupreeta27 notifications@github.comwrote:

@drphilmarshall https://github.com/drphilmarshall what's the convention for the y-axis? my catalogs had y-axis with increasing values downwards.

— Reply to this email directly or view it on GitHubhttps://github.com/drphilmarshall/Lens-Zoo/issues/51#issuecomment-31636498 .

chrissnyder commented 10 years ago

Is it the "tainted by cross-origin data" error? If so, this will work only on spacewarps.org

drphilmarshall commented 10 years ago

I'm not sure. Let's revisit later today once the site is live then? We have this afternoon to fix stuff like this.

On Mon, Jan 6, 2014 at 10:32 AM, Chris Snyder notifications@github.comwrote:

Is it the "tainted by cross-origin data" error? If so, this will work only on spacewarps.org

— Reply to this email directly or view it on GitHubhttps://github.com/drphilmarshall/Lens-Zoo/issues/51#issuecomment-31656849 .

drphilmarshall commented 10 years ago

OK, cross-origin error goes away in beta2 site as predicted, and tutorial code picks up mask=255 values just fine. I just pushed up a classifier without the workaround, so we can test the marking of sims in the stream. Can you merge it in please?

BTW, I noticed that the tutorial message placement is correct in the beta2 site, but was offset low in my local app. I don't think we have squared away all 10 pixel offset issues yet...

chrissnyder commented 10 years ago

Merged and uploaded, but now it detects anywhere on the image as a correct mark placement. Can you confirm I ended with the correct file states for checking the mask? Merging got a bit wonky.

drphilmarshall commented 10 years ago

Looks OK now - great!