FastBitmap fb = new FastBitmap(bitmap); Grayscale g = new Grayscale(fb); g.applyInPlace(fb); Threshold t = new Threshold(100); t.applyInPlace(fb); bitmap = fb.toBitmap();
@Override public String visit(Threshold function) { return String.format("%s (%s)", function.getClass().getSimpleName(), Float.toString(function.getThreshold())); }
public Map<Status, Integer> getHitsByStatusWithIndex(List<StatusWithIndex> statuses) { return getHitsByStatus(statuses.stream() .map(StatusWithIndex::getStatus) .collect(Collectors.toList())); }
@Override public ReductionFunction visit(ThresholdEntity thresholdEntity) { Threshold result = new Threshold(); result.setThreshold(thresholdEntity.getThreshold()); return result; }
final Threshold image = new Threshold(nactiObrazek("DSC03691.jpg"));
@Override public ThresholdResultExplanation explain(BusinessService businessService, Threshold threshold) { final GraphVertex vertex = getGraph().getVertexByBusinessServiceId(businessService.getId()); // Calculate the weighed statuses from the child edges List<StatusWithIndex> statusesWithIndices = weighEdges(getGraph().getOutEdges(vertex)); List<Status> statuses = statusesWithIndices.stream() .map(StatusWithIndex::getStatus) .collect(Collectors.toList()); // Reduce Status reducedStatus = threshold.reduce(statusesWithIndices) .orElse(new StatusWithIndices(MIN_SEVERITY, Collections.emptyList())) .getStatus(); ThresholdResultExplanation explanation = new ThresholdResultExplanation(); explanation.setStatus(reducedStatus); explanation.setHitsByStatus(threshold.getHitsByStatus(statuses)); explanation.setGraphEdges(getGraph().getOutEdges(vertex)); explanation.setWeightStatuses(statuses); explanation.setFunction(threshold); Map<GraphEdge, GraphVertex> graphEdgeToGraphVertex = new HashMap<>(); for (Edge eachEdge : businessService.getEdges()) { GraphVertex vertexForEdge = getGraph().getVertexByEdgeId(eachEdge.getId()); GraphEdge graphEdge = getGraph().getGraphEdgeByEdgeId(eachEdge.getId()); if (vertexForEdge != null && graphEdge != null) { graphEdgeToGraphVertex.put(graphEdge, vertexForEdge); } } explanation.setGraphEdgeToGraphVertexMapping(graphEdgeToGraphVertex); return explanation; }
@Override public Optional<StatusWithIndices> reduce(List<StatusWithIndex> statuses) { final Map<Status, Integer> hitsByStatus = getHitsByStatusWithIndex(statuses); // Determine the status with the highest severity where the number of relative hits // is greater than the configured threshold for (Map.Entry<Status, Integer> statusWithHits : hitsByStatus.entrySet()) { if (statusWithHits.getValue() / (double)statuses.size() >= m_threshold) { return Optional.of(new StatusWithIndices(statusWithHits.getKey(), StatusUtils.getIndicesWithStatusGe(statuses, statusWithHits.getKey()))); } } return Optional.empty(); }
@Override public ReductionFunction visit(ThresholdEntity thresholdEntity) { Threshold result = new Threshold(); result.setThreshold(thresholdEntity.getThreshold()); return result; }
@Override public Optional<StatusWithIndices> reduce(List<StatusWithIndex> statuses) { final Map<Status, Integer> hitsByStatus = getHitsByStatusWithIndex(statuses); // Determine the status with the highest severity where the number of relative hits // is greater than the configured threshold for (Map.Entry<Status, Integer> statusWithHits : hitsByStatus.entrySet()) { if (statusWithHits.getValue() / (double)statuses.size() >= m_threshold) { return Optional.of(new StatusWithIndices(statusWithHits.getKey(), StatusUtils.getIndicesWithStatusGe(statuses, statusWithHits.getKey()))); } } return Optional.empty(); }
FastBitmap fb = new FastBitmap("c:\\files\\image.jpg"); fb.toGrayscale(); Threshold t = new Threshold(120); t.applyInPlace(fb); JOptionPane.showMessageDialog(null, fb.toIcon());
@Override public Void visit(Threshold threshold) { m_thresholdTextField.setValue(String.valueOf(threshold.getThreshold())); return null; }
public Map<Status, Integer> getHitsByStatusWithIndex(List<StatusWithIndex> statuses) { return getHitsByStatus(statuses.stream() .map(StatusWithIndex::getStatus) .collect(Collectors.toList())); }
FastBitmap fb = new FastBitmap(bitmap); //If you want to apply threshold Grayscale g = new Grayscale(); g.applyInPlace(fb); Threshold t = new Threshold(120); t.applyInPlace(fb); bitmap = fb.toBitmap();
@Override public Void visit(Threshold threshold) { m_thresholdTextField.setValue(String.valueOf(threshold.getThreshold())); return null; }
FastBitmap fb = new FastBitmap(bitmap); //If you want to apply threshold Grayscale g = new Grayscale(); g.applyInPlace(fb); Threshold t = new Threshold(120); t.applyInPlace(fb); bitmap = fb.toBitmap();
@Override public AbstractReductionFunctionEntity visit(Threshold threshold) { ThresholdEntity entity = new ThresholdEntity(); entity.setThreshold(threshold.getThreshold()); return entity; }
FastBitmap fb = new FastBitmap(bitmap); Grayscale g = new Grayscale(); g.applyInPlace(fb); Threshold t = new Threshold(120); t.applyInPlace(fb); bitmap = fb.toBitmap(); //Show the result
private ThresholdExplanationWindow(final ThresholdResultExplanation explanation) { setCaption(String.format("Threshold Function Details (%s)", explanation.getFunction().getThreshold())); setClosable(true); setCloseShortcut(ShortcutAction.KeyCode.ESCAPE);
FastBitmap fb = new FastBitmap(bufferedImage); Grayscale g = new Grayscale(); g.applyInPlace(fb); Threshold t = new Threshold(150); t.applyInPlace(fb); //Show the results JOptionPane.showMessageDialog(null, fb.toIcon()); //or if u prefer retrieve the bufferedImage you need to do bufferedImage = fb.toBufferedImage();
FastBitmap fb = new FastBitmap("c:\\yourImage.bmp"); fb.toGrayscale(); Threshold t = new Threshold(120); t.applyInPlace(fb); // Your objects. BlobDetection bd = new BlobDetection(); ArrayList<Blob> blobs = bd.ProcessImage(fb);