image = imread('image.jpg'); [r,c]=size(image); width=10; color=6; new_image=ones(r,c)*color; new_image=uint8(new_image); for row=1:r for column=1:(c-width)/2 new_image(row,column)=image(row,column); end; for column=(c+width)/2:c new_image(row,column)=image(row,column); end; end; for column=1:c for row=1:(r-width)/2 new_image(row,column)=image(row,column); end; for row=(r+width)/2:c new_image(row,column)=image(row,column); end; end; imshow(new_image);
And for the logic of the code this code makes a matrix of ones as the size of image pixels and after that I iterate the code from the matrix and adding the pixels value of original image to the new matrix where the box is not present.
A better approach is to use indexing, eg.:
>> I = imread('peppers.png'); >> N = 10; >> V = 1:N; >> I(fix((end-N)/2)+V,fix((end-N)/2)+V,:) = 6; >> imshow(I)
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.