0

I am trying to use interpolation to remove chromatic aberration from an image. The code I have generates the following error: TypeError: unhashable type: 'numpy.ndarray'. Below is my code - any help would be greatly appreciated. Thank you- Areej This is an input explanation

#splitting an image into its separe bands
source = im.split()
Cfixed = source[2]
Cwarp  = source[1]
#take the image minus a ew-wide edge
roi = [ew+1, xdim-ew, ew+1, ydim-ew];
roi_pad = [roi[0]-ew, roi[1]+ew, roi[2]-ew, roi[3]+ew];
for k in range(0,centers_x.size):
        cx = centers_x[k]
        cy = centers_y[k]
        wz = warps[k]     
import scipy as sp
from scipy import interpolate

def warpRegion(Cwarp, roi_pad, (cx, cy, wz)):
    #Unpack region indices
    sx, ex, sy, ey = roi_pad
    xramp, yramp = np.mgrid[sx:ex+1, sy:ey+1]
    shapeofgrid=xramp.shape
    print 'shape of x grid'+str(shapeofgrid)
    xrampc = xramp - cx;
    yrampc = yramp - cy;
    xramp1 = 1/wz*xrampc;
    yramp1 = 1/wz*yrampc;
    xrampf = xrampc.flatten()
    yrampf = yrampc.flatten() 
    xramp1f = xramp1.flatten()
    yramp1f = yramp1.flatten()
    reg_w = sp.interpolate.interp2d(yrampf,xrampf,Cwarp, yramp1f, xramp1f,'cubic');
5
  • Please add some code that generates example input data (as well as probably the numpy/scipy import statements) Commented Feb 23, 2012 at 11:57
  • source = im.split() Cfixed = source[2] Cwarp = source[1]#take the image minus a ew-wide edge roi = [ew+1, xdim-ew, ew+1, ydim-ew]; Commented Feb 23, 2012 at 12:02
  • I mean add it to the code so that it's a complete but minimal (i.e. without any unimportant extra code) example. You need to help people help you, so if they can take your code and run it directly then you're much more likely to get your problem fixed. Also, can you add the full error message - e.g. including the line number Commented Feb 23, 2012 at 12:11
  • I am so sorry about that I am trying to figure out how to format this properly Commented Feb 23, 2012 at 12:16
  • I reposted the question again at this link stackoverflow.com/questions/9414204/… Commented Feb 23, 2012 at 14:21

2 Answers 2

1

A possible explanation of the error message is that you are trying to use a NumPy array as a dict key or a set element. Look at where the error occurs and study the type of every variable referenced on that line. If you need help, post a runnable example and the full traceback of the exception.

Sign up to request clarification or add additional context in comments.

1 Comment

I reposted the question at this link stackoverflow.com/questions/9414204/…
0

I would recommend using PIL. (Python Image Library)

http://www.pythonware.com/products/pil/

One method would be to: Generate a list of top colours per quadrant/sample area and hash the list

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.