/*Constructor for the class*/ public Edge(EncodeVertex vertOne, EncodeVertex vertTwo, Pixel vertPixOne, Pixel vertPixTwo, int edgeweight) { /*Gives the edge a unique ID*/ this.EdgeID = _edgecounter; _edgecounter++; this.VertexOne = vertOne; this.VertexTwo = vertTwo; this.VertexPixelOne = vertPixOne; this.VertexPixelTwo = vertPixTwo; this.EdgeWeight = edgeweight; }
private List <EncodeVertex> ConstructVertices(List <Pixel> pixelList, int pixelsNeeded, List <byte> secretMessage) { List <EncodeVertex> encodeVertexList = new List <EncodeVertex>(); int counter = 0; for (int i = 0; i < pixelList.Count; i += GraphTheoryBased.SamplesVertexRatio) { EncodeVertex encodeVertex = new EncodeVertex(secretMessage[counter], pixelList[i], pixelList[i + 1], pixelList[i + 2]); //this is hardcoded and can maybe rewritten by using a delegate. encodeVertexList.Add(encodeVertex); counter++; } return(encodeVertexList); }
private bool ConstructASingleEdge(EncodeVertex vertex1, EncodeVertex vertex2, List <Edge> listOfEdges, out int lowestWeight) { int weight = GraphTheoryBased.MaxEdgeWeight; Edge tempEdge = new Edge(null, null, null, null, 0); for (int i = 0; i < GraphTheoryBased.SamplesVertexRatio; i++) { for (int j = 0; j < GraphTheoryBased.SamplesVertexRatio; j++) { if (vertex1.PixelsForThisVertex[i].EmbeddedValue == vertex2.TargetValues[j] && vertex2.PixelsForThisVertex[j].EmbeddedValue == vertex1.TargetValues[i] && CalculateWeightForOneEdge(vertex1.PixelsForThisVertex[i], vertex2.PixelsForThisVertex[j]) <= GraphTheoryBased.MaxEdgeWeight) { //Only have to make one edge for two vertices, but there could potentially be more than 1 pr. 2 vertices if (CalculateWeightForOneEdge(vertex1.PixelsForThisVertex[i], vertex2.PixelsForThisVertex[j]) <= weight) { weight = CalculateWeightForOneEdge(vertex1.PixelsForThisVertex[i], vertex2.PixelsForThisVertex[j]); tempEdge = new Edge(vertex1, vertex2, vertex1.PixelsForThisVertex[i], vertex2.PixelsForThisVertex[j], weight); } } } } if (tempEdge.EdgeWeight != 0) // Edgeweight will never be zero, because a pixel cannot have an embeddedvalue that is // equivalent with it's targetvalue { listOfEdges.Add(tempEdge); lowestWeight = weight; return(true); } lowestWeight = 11; // Random value return(false); }
private void HelpMethodPixelModify(EncodeVertex vertex) { for (int i = 0; i < 1; i++) { int localDifference = 0; if (vertex.PixelsForThisVertex[i].Color.R <= 127) { while (GraphTheoryBased.Mod((vertex.PixelsForThisVertex[i].EmbeddedValue + localDifference), GraphTheoryBased.Modulo) != vertex.TargetValues[i]) { localDifference++; } } else if (vertex.PixelsForThisVertex[i].Color.R > 127) { while (GraphTheoryBased.Mod((vertex.PixelsForThisVertex[i].EmbeddedValue + localDifference), GraphTheoryBased.Modulo) != vertex.TargetValues[i]) { localDifference--; } } vertex.PixelsForThisVertex[i].ColorDifference = localDifference; } }