A tool changing method for a machine tool configured to open and close a shutter provided at an opening in a partition between a machining space and a tool storage space, and change tools by a changing arm between the machining space and the tool storage space through the opening, wherein, when the length of the tool has not been previously input into the database, the method comprises the steps of: capturing an image of a tool with an image capturing device in the tool storage space; calculating a length of the tool based on the captured image; writing the calculated length of the tool in a database; reading the length of the tool from the database; determining an opening width for the shutter as a control parameter for the mechanical operation occurring with the tool change by adding to the length of the tool read from the database a predetermined amount of clearance; and changing the tools between the machining space and the tool storage space through the opening by opening the shutter up to the determined opening width based on the control parameter, and carrying out the mechanical operation occurring with the tool change, and wherein, when the length of the tool has been previously input into the database, the method comprises the steps of: capturing an image of a tool with an image capturing device in the tool storage space; calculating a length of the tool based on the captured image; reading the length of the tool from the database; calculating a difference between the length of the tool obtained based on the captured image and the length of the tool read from the database; generating an alert and stopping the machining process if the difference therebetween is greater than a threshold value; and determining an opening width for the shutter as a control parameter for the mechanical operation occurring with the tool change by adding to the length of the tool read from the database a predetermined amount of clearance, changing the tools between the machining space and the tool storage space through the opening by opening the shutter up to the determined opening width based on the control parameter and carrying out the mechanical operation occurring with the tool change if the difference therebetween is less than the threshold value. capturing an image of a tool with an image capturing device in the tool storage space; calculating a length of the tool based on the captured image; writing the calculated length of the tool in a database; reading the length of the tool from the database; determining an opening width for the shutter as a control parameter for the mechanical operation occurring with the tool change by adding to the length of the tool read from the database a predetermined amount of clearance; and changing the tools between the machining space and the tool storage space through the opening by opening the shutter up to the determined opening width based on the control parameter, and carrying out the mechanical operation occurring with the tool change, capturing an image of a tool with an image capturing device in the tool storage space; calculating a length of the tool based on the captured image; reading the length of the tool from the database; calculating a difference between the length of the tool obtained based on the captured image and the length of the tool read from the database; generating an alert and stopping the machining process if the difference therebetween is greater than a threshold value; and determining an opening width for the shutter as a control parameter for the mechanical operation occurring with the tool change by adding to the length of the tool read from the database a predetermined amount of clearance, changing the tools between the machining space and the tool storage space through the opening by opening the shutter up to the determined opening width based on the control parameter and carrying out the mechanical operation occurring with the tool change if the difference therebetween is less than the threshold value.