Potting Cross-section of an image

11 views (last 30 days)
Aqiba Hafeez
Aqiba Hafeez on 11 Mar 2020
Answered: Bjorn Gustavsson on 11 Mar 2020
Hellow..! I have the following image and I want to plot the cross-section of any three bars (elements of any group of USAF resolution chart), but I dont know how to plot it.. can anyone help me please??

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 11 Mar 2020
First you need to figure out the size of your image - whethre it is an intensity-image or an rgb-image:
imsz = size(img);
Once you know this you need to select row or column to plot
idx_row = 280;
idx_col = 520;
Then were good to start.
subplot(3,3,[1 2 4 5])
imagesc(img)
hold on
plot(idx_col*ones(size(1:imsz(1))),1:imsz(1),'c')
plot(1:imsz(2),idx_row*ones(size(1:imsz(2))),'r')
if numel(imsz) == 3
subplot(3,3,7:8)
rgbplot(squeeze(img(idx_row,:,:)))
subplot(3,3,[3,6])
ph = plot(squeeze(img(:,idx_col,:)),1:imsz(1));
set(ph(1),'color','r')
set(ph(2),'color','g')
set(ph(3),'color','b')
else
subplot(3,3,7:8)
plot(img(idx_row,:))
subplot(3,3,[3,6])
plot(squeeze(img(:,idx_col)),1:imsz(1));
end
From there you can continue with zooming into regions on the row and column-panels as you see fit and then possibly select the corresponding indices and replot only those row or column-parts.
HTH

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!