from numba import jit from PIL import Image import numpy as np import matplotlib.pyplot…
- User
from numba import jit from PIL import Image import numpy as np import matplotlib.pyplot as plt import struct import pandas as pd import math
with open("C:\Users\zoyas\OneDrive\Рабочий стол\владения\учЁбка\стеганография\котлр3.bmp", "rb") as bmp: print('Type:', bmp.read(2).decode()) print('Size: %s' % struct.unpack('I', bmp.read(4))) print('Reserved 1: %s' % struct.unpack('H', bmp.read(2))) print('Reserved 2: %s' % struct.unpack('H', bmp.read(2))) print('bfOffBits: %s' % struct.unpack('I', bmp.read(4)))
codeprint('DIB Header Size: %s' % struct.unpack('I', bmp.read(4))) width = struct.unpack('I', bmp.read(4))[0] height = struct.unpack('I', bmp.read(4))[0] print('width =', width) print('height =', height) """print('Width: %s' % struct.unpack('I', bmp.read(4))) print('Height: %s' % struct.unpack('I', bmp.read(4)))""" print('Colour Planes: %s' % struct.unpack('H', bmp.read(2))) print('Bits per Pixel: %s' % struct.unpack('H', bmp.read(2))) print('Compression Method: %s' % struct.unpack('I', bmp.read(4))) print('Raw Image Size: %s' % struct.unpack('I', bmp.read(4))) print('Horizontal Resolution: %s' % struct.unpack('I', bmp.read(4))) print('Vertical Resolution: %s' % struct.unpack('I', bmp.read(4))) print('Number of Colours: %s' % struct.unpack('I', bmp.read(4))) print('Important Colours: %s' % struct.unpack('I', bmp.read(4)))img = Image.open("C:\Users\zoyas\OneDrive\Рабочий стол\владения\учЁбка\стеганография\котлр3.bmp")
data = np.array(img) display(img)
from scipy.fftpack import dct, idct
def dct_(block): return dct(dct(block.T, norm='ortho').T, norm='ortho')
def idct_(block): return idct(idct(block.T, norm='ortho').T, norm='ortho')
def DCT(x): # Прямое ДКП N = 8 y = np.zeros((N, N)) for k in range(N): if k == 0: C_k = 1/N else: C_k = 2/N for l in range(N): if l == 0: C_l = 1/N else: C_l = 2/N
codefor i in range(N): for j in range(N): y[l,k] += x[j,i]*math.cos(math.pi*k*(2*i+1)/(2*N))*math.cos(math.pi*l*(2*j+1)/(2*N)) y[l,k] *= math.sqrt(C_l*C_k) return y - Assistant
It looks like you're trying to use a function called
displayto visualize images in your code. This function is not defined within the code you've provided, which is why you're receiving the error:"'display' is not defined".In Python, particularly in the context of Jupyter notebooks,
displayis a function provided by IPython to display images and other media objects easily. However, if you're running your code in a standard Python script or in an IDE like VSCode, you need to replacedisplaywith the standard matplotlib method for showing images. - User
что нужно сделать?
- Assistant
Чтобы устранить ошибку
display is not definedв вашем коде, вам нужно заменить функциюdisplay, которая не определена, на код, который использует библиотекуmatplotlibдля отображения изображений. Если вы выполняете код не в Jupyter Notebook, вам следует использоватьmatplotlib.pyplot. Вот шаги, которые вы можете предпринять:-
Импортируйте библиотеку
matplotlib.pyplot, если вы еще не сделали этого. Добавьте в начало вашего кода:pythonimport matplotlib.pyplot as plt -
Замените вызовы
display(img)и другие подобные вызовы на следующий код:Измените:
-