I know this is a lot to ask, but can anyone please help me understand what is happening, and possibly suggest approaches to fix my problem?
I am using the igraph library to solve an image processing problem. I wish to identify two horizontal lines in an image using an S-T cut approach.
My approach works perfectly for a graph representing an image of a certain (small) size. StMincuts of an image of 6xN pixels gives me the answer I expect (in the second cut cut$partition1s[[2]]) however a 7xN pixel image gives the 'wrong' answer. I'm guessing that the problem is probably to do with the link weights but I'm not sure how to solve this.
I have uploaded two graphs in graphml format, one for a 6x10 image and one for a 7x10 image along with the scripts and R image file used to create them.
Many thanks in advance,
Tom
g<-read.graph('graph_6x10.gml',format='graphml')
img<-matrix(0,nrow=6,ncol=10)
img[c(2,4),]<-1
szImg<-c(6,10)
numEl<-6*10
cut<-stMincuts(g,'s','t')
x1<-cut$partition1s[[1]]
x1<-x1[x1<=numEl*2]
x2<-cut$partition1s[[2]]
x2<-x2[x2<=numEl*2]
outimgS1p1<-matrix(0,nrow=szImg[1],ncol=szImg[2])
outimgS2p1<-matrix(0,nrow=szImg[1],ncol=szImg[2])
outimgS1p2<-matrix(0,nrow=szImg[1],ncol=szImg[2])
outimgS2p2<-matrix(0,nrow=szImg[1],ncol=szImg[2])
outimgS1p1[x1[x1<=numEl]]<-1
outimgS2p1[x1[x1>numEl]-numEl]<-1
outimgS1p2[x2[x2<=numEl]]<-1
outimgS2p2[x2[x2>numEl]-numEl]<-1
oldpar<-par(mfrow=c(5,1))
image(outimgS1p1,main='p1,s1')
image(outimgS2p1,main='p1,s2')
image(outimgS1p2,main='p2,s1')
image(outimgS2p2,main='p2,s2')
image(img)
par(oldpar)