フィルターのクリア

How can I find maximums in the intensity profile and display it in the original image ?

2 ビュー (過去 30 日間)
MMSAAH
MMSAAH 2019 年 9 月 13 日
コメント済み: darova 2019 年 9 月 17 日
I have ('liftingbody.png') image and I want to display the intensity profile along a white curve ('sss.png').
I searched the coordinates of the white curve and I displayed the intensity profile of the ('liftingbody.png') along those coordinates.
After that, I searched the maximums in the c profile and I displayed it in the fused image.
My problem is why I got points outside the red curve ? here is my code.
Could anyone help me solving this problem ?
clear all, close all; clc
I2 = imread('liftingbody.png');
figure
imshow(I2);
I=imread('sss.png');
figure
imshow(I);
[x2,y2]=find (I>0); % find the coordinates of white line
[cx,cy,c]=improfile(I2, x2,y2); % display the intensity profile.(cx,xy):coordinates of intensity profile
% [pks,locs] = findpeaks(c);
[pks,locs] = findpeaks(c,'MinPeakDistance',50); % search maximums
figure
plot(c)
% display the curve in red
I = uint8(I);
[x,y,z]=size(I);
for i=1:x
for j=1:y
if (I(i,j)==1)
I(i,j,1)=255;
I(i,j,2)=0;
I(i,j,3)=0;
end
end
end
figure
imshow(I);
title('red curve');
I = imfuse(I, I2,'blend','Scaling','joint');
figure
imshow(I);
hold on
plot(cy(locs(:)),cx(locs(:)),'b*')
  5 件のコメント
darova
darova 2019 年 9 月 13 日
Works ok for me
export_fig_out.png
MMSAAH
MMSAAH 2019 年 9 月 13 日
thank you for your answer but if you zoom in the picture even more, you will see many points outside the red curve.

サインインしてコメントする。

採用された回答

darova
darova 2019 年 9 月 16 日
I think the problem is in order of points. MAthworks help:
improfile
Pixel-value cross-sections along line segments
Try this
I=imread('sss.png');
[x2,y2] = find (I>0); % find the coordinates of white line
figure
imshow(I);
hold on
for i = 1:10:length(x2)
plot(y2(i),x2(i),'.r')
pause(0.1)
end
hold off
And now add this before plot()
[x2 ,ix] = sort(x2); % sort vertically
y2 = y2(ix);
So i divided white line into two parts. Sorted top part vertically and bottom part horizontally
See attached script
  2 件のコメント
MMSAAH
MMSAAH 2019 年 9 月 17 日
Thank you very much. This did solve my problem. I'm really grateful.
The problem was in fact related to the order of points
Could you explain me more please ? How did the sort () command solve the problem ?
Thanks a lot.
darova
darova 2019 年 9 月 17 日
Imagine you have six pixels. You want to find (rows,columns) (position) of them
So order of pixels would be as i marked on the picture
111Untitled.png
Arrows indicate direction of search
So when you have some curve (marked black) and points (red) you have to find improfile
Blue lines will be the actual path of profile
12Untitled.png

サインインしてコメントする。

その他の回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 13 日
編集済み: KALYAN ACHARJYA 2019 年 9 月 13 日
My problem is why I got points outside the red curve ? here is my code?
scatter(cy(locs(:)),cx(locs(:)),'b')
I dot think there are any points positioning the outside the Marker line (white line turned red line), use other plot way and see the results.
345.png
  3 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 13 日
May be there are few white pixels, just near the boundary. When I executed the code, all points are lie on the white line (as showed result)...again trying to visulize the plot.
MMSAAH
MMSAAH 2019 年 9 月 14 日
zoomed_image.JPG
Here is the image zoomed. Many points are outside the red curve.

サインインしてコメントする。


MMSAAH
MMSAAH 2019 年 9 月 16 日
The problem still exists.
Could anyone help me solving this issue please.

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by