Split image using a predefined line
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ben
el 2 de Mayo de 2014
Comentada: Image Analyst
el 3 de Mayo de 2014
Is there anyway to split an image into two using a predefined line that passes through an object's centroid. I have already found the centroid and plotted the line, but I am unsure of how to separate the image using this line. Many Thanks
2 comentarios
Respuesta aceptada
Image Analyst
el 2 de Mayo de 2014
Sure. I'm going to assume the line cuts across the entire image. Then use poly2mask() to create a binary image.
mask = poly2mask(x, y);
Then you can either blacken above/below the line.
imageAbove = grayImage;
imageAbove(mask) = 0;
imageBelow = grayImage;
imageBelow(~mask) = 0;
You can also crop to the bounding box or leave it at the original size, using imcrop() or regular indexing.
5 comentarios
Image Analyst
el 3 de Mayo de 2014
Ben, it's just simple algebra. I simply used the point slope formula for a line. See attached test3.m file to produce the image below.

Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
