How to assign an image to another with a black frame?

조회 수: 1 (최근 30일)
Edwin Joy
Edwin Joy 2019년 3월 2일
편집: Edwin Joy 2019년 3월 2일
I used the code given below to assign another picture to a black filled picture. The given picture has to fit into the black background at the center so that it looks as if it is framed.
But the result is:
1.JPG
I'd like the pic I loaded, (that is j) inside the box. I tried a lot! Please help! Many thanks in advance! :)
j=imread('1.jpg');
[na, nb, nc]=size(j);
b=40;
j_big=zeros(na+2*b, nb+2*b, nc);
j_big(b+1:b+na, b+1:b+nb, :)=j;
imshow(j_big);

채택된 답변

Image Analyst
Image Analyst 2019년 3월 2일
Why not just use padarray()?
  댓글 수: 1
Edwin Joy
Edwin Joy 2019년 3월 2일
편집: Edwin Joy 2019년 3월 2일
Oh okay. Thank you!
But I still don't understand why I just get some pixels scattered around the image when I use the code mentioned. I even tried to use loops and copy pixel by pixel to find out the error but it's still giving me the same result.
EDIT:
Yay! I got it. Well it appeared when I changed the array to unsigned int8.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by