#
#	This is Sub Makefile for NoiseAdd.
#

#### Input extention ####
# Defined at Main

#### Suffixes rule ####

#### INCLUDE ####
# Use TIPS File.
# -include ${EOS_HOME}/tutorial/TIPS/XXXX/Makefile/Makefile-lib

#### Definition ####
# Defined at Main

#### Rules of the list created ####


##### Commands #####
NoiseAdd::
	@if [ -z "$(NOISE_OUT_FILE_NAME)" ] ; then \
		outfile="$(NOISE_IN_FILE_NAME)"; \
	else \
		outfile="$(NOISE_OUT_FILE_NAME)"; \
	fi; \
	if [ -z "$(OUT_NOISE)" ] ; then \
		outext="$(IN_NOISE)"; \
	else \
		outext="$(OUT_NOISE)"; \
	fi; \
	if [ "$$outfile""$$outext" = "$(NOISE_IN_FILE_NAME)""$(IN_NOISE)" ] ; then \
		inext="$(IN_NOISE)back"; \
		mv "$(NOISE_IN_FILE_NAME)"."$(IN_NOISE)" "$(NOISE_IN_FILE_NAME)"."$$inext"; \
	else \
		inext="$(IN_NOISE)"; \
	fi; \
	if [ ! -z "$(NOISE_SD)" ] ; then \
		Option="$$Option -SD $(NOISE_SD)"; \
	fi; \
	if [ ! -z "$(NOISE_NS)" ] ; then \
		Option="$$Option -NS $(NOISE_NS)"; \
	fi; \
	if [ ! -z "$(NOISE_SN)" ] ; then \
		Option="$$Option -SN $(NOISE_SN)"; \
	fi; \
	if [ ! -z "$(NOISE_H_TRES)" ] ; then \
		Option="$$Option -H $(NOISE_HTRES)"; \
	fi; \
	if [ ! -z "$(NOISE_L_TRES)" ] ; then \
		Option="$$Option -L $(NOISE_LTRES)"; \
	fi; \
	mrcImageNoiseAdd -i "$(NOISE_IN_FILE_NAME)"."$$inext" -o "$$outfile"."$$outext" $$Option

help_NoiseAdd::
	@echo
	@echo "NoiseAdd"
	@echo "This is Sub Makefile to add noise to an image."
	@echo
	@echo "	(Command):"
	@echo "		NoiseAdd:		Add Noise to input file. (if input name = output name, input is renamed.)"
	@echo
	@echo "	(Setting Data):"
	@echo "		NOISE_IN_FILE_NAME:	Inout file name."
	@echo "		IN_NOISE:		Input extention."
	@echo "		(Option)"
	@echo "		NOISE_OUT_FILE_NAME:	Outout file name. (if empty, it is same as input.)"
	@echo "		OUT_NOISE:		Output extention. (if empty, it is same as input.)"
	@echo "		NOISE_SD:		standard deviation of noise."
	@echo " 		NOISE_NS:		NS ratio"
	@echo " 		NOISE_SN:		SN ratio"
	@echo " 		NOISE_H_TRES:		High threshold to adding noise."
	@echo " 		NOISE_L_TRES:		Low threshold to adding noise."
	@echo

##### Commands(Input to Output) #####

