How to rewind the curve by 180 degrees?

3 ビュー (過去 30 日間)
Veronika
Veronika 2017 年 4 月 24 日
コメント済み: Veronika 2017 年 4 月 24 日
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')
Veronika
Veronika 2017 年 4 月 24 日
Thank you it helps me so much!

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by