필터 지우기
필터 지우기

How to rewind the curve by 180 degrees?

조회 수: 1 (최근 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 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