How to rewind the curve by 180 degrees?

1 次查看(过去 30 天)
Dear all,
I created curve by fourier_fit function in figure, but I would like to opposite direction (Rotate the curve by 180 degrees). I don´t know, why is curve plotted like this. I attach original image and also Model.m, which I created fourier_fit function. This is my code:
fontSize = 15;
% baseFileName = '110.jpg';
baseFileName = 'thorax-mdl.jpg';
folder = pwd
fullFileName = fullfile(folder, baseFileName);
% Načtení obrazu.
grayImage = imread(fullFileName);
grayImage_pater = imread (fullFileName);
% ***
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% Máme barevný obraz, musíme ho převést na černobílý = vybereme zelený kanál
grayImage = grayImage(:, :, 2); % zelený kanál
end
eq_grayImage = histeq(grayImage);%ekvalizace pomocí histogramu obrazu
[rows, columns, numberOfColorChannels] = size(grayImage_pater);
if numberOfColorChannels > 1
% Máme barevný obraz, musíme ho převést na černobílý = vybereme zelený kanál
grayImage_pater = grayImage_pater(:, :, 2); % zelený kanál
grayImage_pater(425:end, :) = 0;
end
eq_grayImage_pater = histeq(grayImage_pater);
thresholdValue = 170;
binaryImage = grayImage < thresholdValue;
% Odstranění okolí.
binaryImage = imclearborder(binaryImage);
% Vyplnění otvorů.
binaryImage = imfill(binaryImage, 'holes');
se = strel('line',5,100);
%binaryImage= imdilate(binaryImage,se);
% Práh pro vytvoření binárního obrazu páteře.
bodyMask = grayImage > 128;
% Get rid of white surround.
bodyMask = imclearborder(bodyMask);
% Extract the largest blob only.
bodyMask = bwareafilt(bodyMask, 1);
binaryImage_pater = bodyMask & (grayImage > 220);
% Fill holes.
binaryImage_pater= imfill(binaryImage_pater, 'holes');
binaryImage_pater = bwareaopen(binaryImage_pater,197);
%Find areas.
labeledImage = bwlabel(binaryImage_pater);
se = strel('line',5,100);
%binaryImage_pater= imdilate(binaryImage_pater,se);
%Práh pro vytvoření binárního obrazu okolí
thresholdValue = 180;
binaryImage_okoli = eq_grayImage > thresholdValue;
% Odstranění okolí.
binaryImage_okoli = imclearborder(binaryImage_okoli);
% Vyplnění otvorů.
binaryImage_okoli = imfill(binaryImage_okoli, 'holes');
% Vymazání menších otvorů.
binaryImage_okoli = bwareaopen(binaryImage_okoli, 750);
se = strel('line',5,100);
Npts1 = 20; % počet bodů interpolovaných hranic
Ncomps = 20; % počet fourierových komponentů
shape.thorax=Model(binaryImage_okoli,Ncomps,100);
figure()
tmp=shape.thorax{1};
se = strel('square',5);
erodedBW = imerode(binaryImage_okoli,se);
shape.thorax=Model(erodedBW,Ncomps ,30);
tmp = shape.thorax{1};
plot(tmp(:,2), tmp(:,1), 'o-b')
Can you advice me? Thank you for your answers.
  4 个评论
Rik
Rik 2017-4-24
编辑:Rik 2017-4-24
You can't, unless you convert the figure to an image (DON'T do that).
Think really hard about what you want on each axis, and you will be fine. Look at the differences between the output for the lines below.
plot(tmp(:,1), tmp(:,2), 'o-b')
plot(tmp(:,2), tmp(:,1), 'o-b')
plot(tmp(:,1),-tmp(:,2), 'o-b')
plot(tmp(:,2),-tmp(:,1), 'o-b')
plot(-tmp(:,1), tmp(:,2), 'o-b')
plot(-tmp(:,2), tmp(:,1), 'o-b')
plot(-tmp(:,1),-tmp(:,2), 'o-b')
plot(-tmp(:,2),-tmp(:,1), 'o-b')

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by