MATLAB Answers

Project data for each pixel along the edge direction

조회 수: 4(최근 30일)
Pitsinee Yuen
Pitsinee Yuen 28 Aug 2019
편집: Pitsinee Yuen 30 Aug 2019
I have a slanted-edge image that I would like to project data for each pixel along the edge direction same way as the picture below.00046_psisdg10023_100231c_page_2_2.jpg
any idea to do this?

  댓글 수: 0

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


Johannes Fischer
Johannes Fischer 28 Aug 2019
Do you know the angle? You could rotate the image to align the edge with the grid and then project along one dimension:
%% example preparation
% create edge
img = zeros(100,100);
img(:, 50:100) = 1;
theta = 10; % deg
% create slanted edge
imgR = imrotate(img, theta, 'bilinear');
%% solution
% align slanted edge with grid
imgRR = imrotate(imgR, -theta, 'bilinear');
% project image data of both images
projectionR = sum(imgR, 1);
projectionRR = sum(imgRR, 1);
subplot(1, 3, 1)
title('original image')
subplot(1, 3, 2)
title('rotated image')
subplot(1, 3, 3)
hold on
Bear in mind, that imrotate adds zeros to contain all the infomation in the rotated image. Adding zeros does of course not interfere with the summation, but you need to make sure that the alignment is correct.

  댓글 수: 1

Pitsinee Yuen
Pitsinee Yuen 30 Aug 2019
Thank you Johannes Fischer for comment. I tried your code with my image. When the image rotated, It will have black boarder that make the projection not in s-shape.

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

Community Treasure Hunt

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

Start Hunting!

Translated by