How do I apply a window on an image to keep the part in the window while reduce the resolution (clarity) of the remaining part of the picture?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
D_coder
el 21 de Mzo. de 2020
Respondida: Image Analyst
el 21 de Mzo. de 2020
Suppose I have an image with three circles and a line as shown below. I want to apply a trapezoidal type window (see dotted lines) over certain x axis range to preserve the resolution in that section while reducing the resolution in the remaining part of the picture
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278441/image.png)
0 comentarios
Respuesta aceptada
Image Analyst
el 21 de Mzo. de 2020
Use poly2mask() to make a mask of the part you want to preserve. Then blur the whole image with imfilter() or conv2(). Then replace the image in the mask with the original. Something like
[rows, columns, numberOfColorChannels] = size(grayImage);
mask = poly2mask(x, y, rows, columns);
kernel = ones(9,9);
kernel = kernel / sum(kernel(:)); % Normalize so we don't change the mean intensity of the image.
blurredImage = conv2(grayImage, kernel, 'same'); % Blurs everything, including the masked region.
blurredImage(mask) = grayImage(mask); % Restore original to the masked region.
x and y are the points of the vertices of your trapezoid.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Image Processing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!