how to create a fan shape/ arc inside an image?

I want to change the rectangular into fan-shape or arc.

3 Comments

Is that an image being displayed with image/imagesc/imshow/pcolor, or is it a contourf plot?
The difference is whether we're trying to stack objects in a figure or trying to directly modify a raster image.
Alternatively, are we trying to add an arc object to the image, or are we trying to distort the existing image into an arc?
Why don't you s how us your expectations as an example image if possible.
@DGM@KSSVit's one image and I want to convert the rectangular into fan-shape/polar (attached is the example of the fan-shape). In fact, the rect's image is done in python, here is the code:
roi_upper = 310
roi_lower = 140
roi_left = 80
roi_right = 525
rec = np.zeros(df.shape, dtype=m_df.dtype)
rec[roi_lower:roi_upper,roi_left:roi_right] = 1
img_ro = df * rec

Sign in to comment.

Answers (1)

May be something like this:
[I,map] = imread('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1152743/rect.png') ;
[m,n,p] = size(I) ;
R = linspace(0.5,1,n) ;
th = linspace(pi/4,3*pi/4,m) ;
[R,T] = meshgrid(R,th) ;
X = R.*cos(T) ;
Y = R.*sin(T) ;
warp(X,Y,ones(size(X)),I)
view(2)

3 Comments

@KSSVthank you for this, but this converts the whole image, I want to convert the rectangular inside the image.
You may use imcrop and pick the part of the image you want.
@KSSVdo you have an idea to convert your code into python so I can try on that on original image?

Sign in to comment.

Tags

Asked:

BA
on 11 Oct 2022

Commented:

BA
on 12 Oct 2022

Community Treasure Hunt

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

Start Hunting!