Performs actual projection using specified method.
()
| 304 | |
| 305 | /** Performs actual projection using specified method. */ |
| 306 | @AstroImageJ(reason = "Merge FITS headers as well; Force makeOutputImage to always return a FloatProcessor", modified = true) |
| 307 | public void doProjection() { |
| 308 | if (imp==null) |
| 309 | return; |
| 310 | if (method<AVG_METHOD || method>MEDIAN_METHOD) |
| 311 | method = AVG_METHOD; |
| 312 | if (imp.getBitDepth()==24) { |
| 313 | doRGBProjection(); |
| 314 | return; |
| 315 | } |
| 316 | if (imp.getBitDepth()==32 && method==AVG_METHOD) { |
| 317 | projImage = doAverageFloatProjection(imp); |
| 318 | return; |
| 319 | } |
| 320 | sliceCount = 0; |
| 321 | for (int slice=startSlice; slice<=stopSlice; slice+=increment) |
| 322 | sliceCount++; |
| 323 | if (method==MEDIAN_METHOD) { |
| 324 | projImage = doMedianProjection(); |
| 325 | // Merge Fits headers |
| 326 | mergeFitsHeaders(method, startSlice, stopSlice, increment, imp, projImage); |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | // Create new float processor for projected pixels. |
| 331 | FloatProcessor fp = new FloatProcessor(imp.getWidth(),imp.getHeight()); |
| 332 | ImageStack stack = imp.getStack(); |
| 333 | RayFunction rayFunc = getRayFunction(method, fp); |
| 334 | if (IJ.debugMode==true) { |
| 335 | IJ.log("\nProjecting stack from: "+startSlice |
| 336 | +" to: "+stopSlice); |
| 337 | } |
| 338 | |
| 339 | // Determine type of input image. Explicit determination of |
| 340 | // processor type is required for subsequent pixel |
| 341 | // manipulation. This approach is more efficient than the |
| 342 | // more general use of ImageProcessor's getPixelValue and |
| 343 | // putPixel methods. |
| 344 | int ptype; |
| 345 | if (stack.getProcessor(1) instanceof ByteProcessor) ptype = BYTE_TYPE; |
| 346 | else if (stack.getProcessor(1) instanceof ShortProcessor) ptype = SHORT_TYPE; |
| 347 | else if (stack.getProcessor(1) instanceof FloatProcessor) ptype = FLOAT_TYPE; |
| 348 | else { |
| 349 | IJ.error("Z Project", "Non-RGB stack required"); |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | // Do the projection |
| 354 | int sliceCount = 0; |
| 355 | for (int n=startSlice; n<=stopSlice; n+=increment) { |
| 356 | if (!isHyperstack) { |
| 357 | IJ.showStatus("ZProjection " + color +": " + n + "/" + stopSlice); |
| 358 | IJ.showProgress(n-startSlice, stopSlice-startSlice); |
| 359 | } |
| 360 | projectSlice(stack.getPixels(n), rayFunc, ptype); |
| 361 | sliceCount++; |
| 362 | } |
| 363 |
no test coverage detected