Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

i am getting this error please help me ?

5 vues (au cours des 30 derniers jours)
Rishith Reddy
Rishith Reddy le 24 Oct 2022
Clôturé : DGM le 24 Oct 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 commentaire
Jan
Jan le 24 Oct 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.

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by