I am attempting to straighten and crop an image by using Edge Detection. The original image looks like this. By using edge detection and finding the max and min values for the points regarding the corners, I am able to get this.
However, I would like it to be perfectly straight, so that I can break it up into 10 (originally this was 20, but I realized 10 would suffice) perfect slices along the bars. Yes, I realize that I am currently only working with two points, but I would locate the coordinates of the other two points for the final version.
Is there a function that I can input all four corners into— have it crop the image according to those points, and have it transform the cropped image into a straightened rectangle of a given size?
Thank you very much in advance.
Here is the code I am currently working with:
i = Import["Images/1.JPG"]
corners = ImageCorners[i, 3, .01, 5]
minX = Min[corners[[;; , 1]]]
maxX = Max[corners[[;; , 1]]]
minY = Min[corners[[;; , 2]]]
maxY = Max[corners[[;; , 2]]]
z = ImageTrim[i, {{minX, minY}, {maxX, maxY}}]
imageData = ImagePartition[z, Scaled[{1/10, 1}]][[1, ;;]]
quantifyBar[x_] := Total[ImageMeasurements[x, "Mean"]]
classifyBar[x_] := If[x < 1.75, 1, 0]
For[x = 1, x < Length[imageData] + 1, x++,
Print[classifyBar[quantifyBar[imageData[[x]]]]]]
ImageTake
? You can specify rows and columns that you want to take from the image. Also I don't understand what you mean by straightened rectangle. Do you want to detect the edges and cut along them? $\endgroup$