def get_image_filter_spider(request): """ Function to get the computing image with a spider filter applied """ pars={} imagePath = request.GET.get('image', None) dim = request.GET.get('dim', None) filterType = int(request.GET.get('filterType', None)) pars["filterType"] = filterType pars["filterMode"] = int(request.GET.get('filterMode', None)) pars["usePadding"] = request.GET.get('usePadding', None) pars["op"]="FQ" # Copy image to filter to Tmp project folder outputName = os.path.join("Tmp", "filtered_particle") outputPath = outputName + ".spi" outputLoc = (1, outputPath) ih = ImageHandler() ih.convert(xmippToLocation(imagePath), outputLoc) outputLocSpiStr = locationToSpider(1, outputName) # check values if filterType < 2: pars["filterRadius"] = request.GET.get('radius', None) else: pars["highFreq"] = float(request.GET.get('highFreq', None)) pars["lowFreq"] = float(request.GET.get('lowFreq', None)) if filterType == 2: pars["temperature"] = request.GET.get('temperature', None) filter_spider(outputLocSpiStr, outputLocSpiStr, **pars) # Get output image and update filtered image img = xmipp.Image() locXmippStr = locationToXmipp(1, outputPath) img.read(locXmippStr) # from PIL import Image img = getPILImage(img, dim) response = HttpResponse(mimetype="image/png") img.save(response, "PNG") return response
def get_image_filter_spider(request): """ Function to get the computing image with a spider filter applied """ pars = {} imagePath = request.GET.get('image', None) dim = request.GET.get('dim', None) filterType = int(request.GET.get('filterType', None)) pars["filterType"] = filterType pars["filterMode"] = int(request.GET.get('filterMode', None)) pars["usePadding"] = request.GET.get('usePadding', None) pars["op"] = "FQ" # Copy image to filter to Tmp project folder outputName = os.path.join("Tmp", "filtered_particle") outputPath = outputName + ".spi" outputLoc = (1, outputPath) ih = ImageHandler() ih.convert(xmippToLocation(imagePath), outputLoc) outputLocSpiStr = locationToSpider(1, outputName) # check values if filterType < 2: pars["filterRadius"] = request.GET.get('radius', None) else: pars["highFreq"] = float(request.GET.get('highFreq', None)) pars["lowFreq"] = float(request.GET.get('lowFreq', None)) if filterType == 2: pars["temperature"] = request.GET.get('temperature', None) filter_spider(outputLocSpiStr, outputLocSpiStr, **pars) # Get output image and update filtered image img = xmipp.Image() locXmippStr = locationToXmipp(1, outputPath) img.read(locXmippStr) # from PIL import Image img = getPILImage(img, dim) response = HttpResponse(mimetype="image/png") img.save(response, "PNG") return response
def _preprocessParticleRow(self, img, imgRow): if self._imgPath: # Create a link or copy files to extraPath # and update the Row properly index, fn = xmippToLocation(imgRow.getValue(md.MDL_IMAGE)) imgBase = basename(fn) imgDst = self.protocol._getExtraPath(imgBase) if not exists(imgDst): self.copyOrLink(join(self._imgPath, fn), imgDst) imgRow.setValue(md.MDL_IMAGE, locationToXmipp(index, imgDst)) if self._micIdOrName: micId = imgRow.getValue(md.MDL_MICROGRAPH_ID, None) micName = imgRow.getValue(md.MDL_MICROGRAPH, None) # Check which is the key to identify micrographs (id or name) if micId is not None: micKey = micId else: micKey = micName mic = self.micDict.get(micKey, None) # First time I found this micrograph (either by id or name) if mic is None: mic = Micrograph() mic.setObjId(micId) if micName is None: micName = self.protocol._getExtraPath('fake_micrograph%6d' % micId) mic.setFileName(micName) self.micSet.append(mic) # Update dict with new Micrograph self.micDict[micKey] = mic # Update the row to set a MDL_MICROGRAPH_ID imgRow.setValue(md.MDL_MICROGRAPH_ID, long(mic.getObjId()))