Info
This question is closed. Reopen it to edit or answer.
i am getting this error please help me ?
1 view (last 30 days)
Show older comments
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 Comment
Jan
on 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.
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!