PLEASE HELP! Repeated segments in image

2 vues (au cours des 30 derniers jours)
Jane
Jane le 3 Déc 2013
Réponse apportée : Jane le 3 Déc 2013

Hello,

I pasted several leg segments onto a black background; however, some of the smaller leg segments are repeated. It should only be pasted once. Why is this happening? Please help asap! Thank you.

code adapted from Image Analyst

if true
  % %% ALIGN ALL LEG SEGMENTS
clc;    % Clear the command window.
close all;  % Close all figures (except those of imtool.)
imtool close all;  % Close all imtool figures.
clear;  % Erase all existing variables.
workspace;  % Make sure the workspace panel is showing.
fontSize = 20;
format compact;
%
grayImage = imread('Blackout.png');
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[I1R I1C numberOfColorBands] = size(grayImage);
% 
% imread smaller image
rotatedImage2=imread('rotCoxa.png');
[I2R I2C] = size(rotatedImage2);
rotatedImage3=imread('rotTrochanter.png');
[I3R I3C] = size(rotatedImage3);
rotatedImage4=imread('rotFemur.png');
[I4R I4C] = size(rotatedImage4);
rotatedImage5=imread('rotTarsus5.png');
[I5R I5C] = size(rotatedImage5);
rotatedImage6=imread('rotTarsus4.png');
[I6R I6C] = size(rotatedImage6);
rotatedImage7=imread('rotTarsus3.png');
[I7R I7C] = size(rotatedImage7);
rotatedImage8=imread('rotTarsus2.png');
[I8R I8C] = size(rotatedImage8);
rotatedImage9=imread('rotTarsus1.png');
[I9R I9C] = size(rotatedImage9);
rotatedImage10=imread('rotTarsus0.png');
[I10R I10C] = size(rotatedImage10);
%
% Paste it onto the original image
% Coxa
x = 1;
y = I1R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I2R - 1;
c2 = c1 + I2C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage2(1:(r2-r1+1), 1:(c2-c1+1));
%
% Trochanter
x = I2C;
y = I1R/2+I2R/2-I3R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I3R - 1;
c2 = c1 + I3C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage3(1:(r2-r1+1), 1:(c2-c1+1));
%
%Femur
x = I2C+I3C;
y = I1R/2+I2R/2-I4R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I4R - 1;
c2 = c1 + I4C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage4(1:(r2-r1+1), 1:(c2-c1+1));
%
%Tarsus 5
x = I2C+I3C+I4C;
y = I1R/2+I2R/2-I5R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I5R - 1;
c2 = c1 + I5C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage5(1:(r2-r1+1), 1:(c2-c1+1));
%
%Tarsus 4
x = I2C+I3C+I4C+I5C;
y = I1R/2+I2R/2-I6R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I6R - 1;
c2 = c1 + I6C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage6(1:(r2-r1+1), 1:(c2-c1+1));
%
%Tarsus 3
x = I2C+I3C+I4C+I5C+I6C;
y = I1R/2+I2R/2-I7R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I7R - 1;
c2 = c1 + I7C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage7(1:(r2-r1+1), 1:(c2-c1+1));
%
%Tarsus 2
x = I2C+I3C+I4C+I5C+I6C+I7C;
y = I1R/2+I2R/2-I8R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I8R - 1;
c2 = c1 + I8C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage8(1:(r2-r1+1), 1:(c2-c1+1));
%
%Tarsus 1
x = I2C+I3C+I4C+I5C+I6C+I7C+I8C;
y = I1R/2+I2R/2-I9R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I9R - 1;
c2 = c1 + I9C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage9(1:(r2-r1+1), 1:(c2-c1+1));
%
%Tarsus 0
x = I2C+I3C+I4C+I5C+I6C+I7C+I8C+I9C;
y = I1R/2+I2R/2-I10R/2;
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + I10R - 1;
c2 = c1 + I10C - 1;
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = rotatedImage10(1:(r2-r1+1), 1:(c2-c1+1));
%
imshow(grayImage);
axis on;
title('Aligned Image', 'FontSize', fontSize);
% 
% Save rotated image
imwrite(grayImage, 'alignedImage.png');
end

Réponses (1)

Jane
Jane le 3 Déc 2013
Figured it out! Sorry for the frequent questions today. This is due tomorrow for a course, but I just finished so no more questions for today!
I just had to replace with this.
if true
% rotatedImage2=imread('rotCoxa.png');
[I2R I2C color2] = size(rotatedImage2);
rotatedImage3=imread('rotTrochanter.png');
[I3R I3C color3] = size(rotatedImage3);
rotatedImage4=imread('rotFemur.png');
[I4R I4C color4] = size(rotatedImage4);
rotatedImage5=imread('rotTarsus5.png');
[I5R I5C color5] = size(rotatedImage5);
rotatedImage6=imread('rotTarsus4.png');
[I6R I6C color6] = size(rotatedImage6);
rotatedImage7=imread('rotTarsus3.png');
[I7R I7C color7] = size(rotatedImage7);
rotatedImage8=imread('rotTarsus2.png');
[I8R I8C color8] = size(rotatedImage8);
rotatedImage9=imread('rotTarsus1.png');
[I9R I9C color9] = size(rotatedImage9);
rotatedImage10=imread('rotTarsus0.png');
[I10R I10C color10] = size(rotatedImage10);
end

Catégories

En savoir plus sur Display Image dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by