How to use Image Iterators in right way

Here is my rewrite code ,now program is faster than before .

using IteratorType = itk::ImageRegionIteratorWithIndex<ImageType>;

IteratorType outputIt(image, image->GetLargestPossibleRegion());

for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt)
{
	ImageType::IndexType idx = outputIt.GetIndex();
	//idx[0] = requestedIndex[0] + requestedSize[0] - 1 - idx[0];
	if (outputIt.Get() != 0) {
	
		slicecoordinates.push_back(idx[2]);//
		Ycoordinates .push_back(idx[1]);//
		Xcoordinates .push_back(idx[0]);//
	
}

I love Iterator