Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CHANGE THIS CODE TO A NEW CODE WITHOUT AFFECTING ITS ORIGINAL FUNCTION. PLEASE DO IT WITH ADD-ON CODES OR WITH REPLACING CERTAIN PARAMETERS public void
CHANGE THIS CODE TO A NEW CODE WITHOUT AFFECTING ITS ORIGINAL FUNCTION. PLEASE DO IT WITH ADD-ON CODES OR WITH REPLACING CERTAIN PARAMETERS
public void findClusters() { clusters = new ArrayList<>();//initial ans list or erase previous answer INearestNeighbors neighborsFinder = new NearestNeighbors(points); for (IPoint3D current : points) { //single point processor if (current.getClusterID() != -1)//processed and skip continue; List neighbors = neighborsFinder.rangeQuery(eps, current);//find neighbors if (neighbors.size() < minPts)//if not enough neighbors { for (IPoint3D noise : neighbors) { noise.markNoise();//mark all neighbors as noise } continue; } int id = PointCluster.assignNewID(this.clusters); List rgb = PointCluster.assignNewRGB(this.clusters); IPointCluster newCluster = new PointCluster(id, rgb.get(0), rgb.get(1), rgb.get(2)); newCluster.addPoint(current); Stack pending = new Stack<>(); pending.addAll(neighbors);//process neighbors while (!pending.isEmpty()) { IPoint3D currentNeighbor = pending.pop(); if (currentNeighbor.getClusterID() >= 1)//processed and skip(dont skip noise) continue; newCluster.addPoint(currentNeighbor); List neighborsOfNeighbor = neighborsFinder.rangeQuery(eps, currentNeighbor);//find neighbors if (neighborsOfNeighbor.size() >= minPts)//if enough neighbors { pending.addAll(neighborsOfNeighbor);//process neighbors } } this.clusters.add(newCluster); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started