How to make a rectangular shape with inner boundary having the value of 1 and outer boundary a value of 0?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to make a rectangular shape with inner boundary value set as one and outer boundary value set as zero. Ideally a smoother transition from inner boundary to put boundary would be really helpful for my case. Following figure can explain the problem better:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/839970/image.jpeg)
In my implementation, I am struggling with the corners in particular with a linear transition from inner to outer boundary.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/839975/image.png)
Following line should run the function to reproduce the the results of figure 2:
jQvals(Trow,Tcol,ouc,our,inc,inr,ptAbvCrk,ptBlwCrk,gridElems);
Relevant variable are in the attached mat file.
Looking forward to the feedback.
3 个评论
采纳的回答
Matt J
2021-12-20
编辑:Matt J
2021-12-20
For example,
A=zeros(100);
A(30:70,30:70)=1;
A=max(0, 1-bwdist(A)/10);
A( abs( conv2(A,ones(3)/9,'same')-1)<=1e-6)=0;
imshow(A)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!