[Python] For image analysis on mac, how do I prevent this error: Python[19607:217577]...

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    For multiple image analysis projects in python, I keep getting these two errors below:

    Error 1: Python[19607:217577] +[IMKClient subclass]: chose IMKClient_Legacy Error 2: Python[19607:217577] +[IMKInputSession subclass]: chose IMKInputSession_Legacy

    I want to use mac, and have tried using jupyter notebook, pycharm, and python in terminal to work around it.

    Below is one example of program that gives such error (other programs I have also give such errors).

    import numpy as np
    import scipy.fftpack as fp
    from skimage.io import imread
    import random

    @np.vectorize
    def func(x):
    if x==0: x=random.choice([-0.001,0.001])
    return x
    @np.vectorize
    def safe_divide(top,bottom):
    try:
    out=np.divide(top,botton)
    except:
    out=top
    return out

    def gaussian_notch(sz, D0, W):
    h, w = sz
    u, v = np.meshgrid(range(-w//2,w//2), range(-h//2,h//2)) # assuming w, h even
    D = func(np.sqrt(u**2 + v**2))
    return 1-np.exp(safe_divide(-(D**2-D0**2)**2,(D*W)**2))

    f = imread('house.png', as_gray=True)
    f = f / f.max()
    D0, W = 30, 20
    F = fp.fftshift(fp.fft2(f))
    H = gaussian_notch(f.shape, D0, W)
    G = H * F
    g = np.abs(fp.ifft2(G))
    g = g / g.max() # normalize

    import matplotlib.pyplot as plt
    import matplotlib.image as mpimg
    img = mpimg.imread('house.png')
    imgplot = plt.imshow(img)
    imgplot = plt.imshow(g)
    plt.show()

    Continue reading...

Compartilhe esta Página