Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

i am getting this error please help me ?

2 Ansichten (letzte 30 Tage)
Rishith Reddy
Rishith Reddy am 24 Okt. 2022
Geschlossen: DGM am 24 Okt. 2022
i=imread("Lena512.png")
i_i=im2double(i);
k=ones(4,4)/16;
b=1
conv2d(i_i,k,b)
function conv2d(i,k,b)
[m,n]= size(k);
[y,x]=size(i);
y=y-m+1;
x=x-m+1;
ni=zeros(y,x)
for l=2:1:y
for j=2:1:x
ni(l,j)=sum(i(l:l+m-1,j:j+n-1)*k)+b
end
end
end
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-4.
ni(l,j)=sum(i(l:l+m-1,j:j+n-1)*k)+b
the respective pyhon code is working
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 24 21:29:27 2022
@author: rishi
"""
import numpy as np
import cv2
import os
os.chdir(r"C:\Users\rishi\Downloads")
image=cv2.imread("Lena512.png")
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
k=np.ones([4,4],dtype='int')/16
def convolution2d(image, kernel,bias):
m, n = kernel.shape
if (m == n):
y, x = image.shape
y = y - m + 1
x = x - m + 1
new_image = np.zeros((y,x))
for i in range(y):
for j in range(x):
new_image[i][j] = np.sum(image[i:i+m, j:j+m]*kernel) + bias
return new_image
x=convolution2d(image,k,bias=1)
cv2.imwrite('blurrey.jpg',x)
  1 Kommentar
Jan
Jan am 24 Okt. 2022
Is this the same question as https://www.mathworks.com/matlabcentral/answers/1833963-i-am-getting-this-error ? Then please delete one of them before somebody posts an anwer.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by