Rotate randomly orientated, long blobs to be horizontal in vb.net?
In my fish measuring program I can find the length and width of the fish using
BlobExplorer. However, if a fish is photographed a random angle, then my
measuring will not be accurate. I would like to use blob repositioning, blob
repositioning2, or blob balance to make blobs orientated horizontally.
So far I have been trying to use the filters test code for BlobRepositioning
but there are parts I do not understand.
if panelActif=pBlobRepositioning then begin
// to test this filter, we need to do somethings
preprocessSimulateAngle(imageIn,StrToFloat(txtBlobRepositioningSimulateAngle.T
ext)); // this function set //'imageSimulateAngle'
chrono.Start;
setParameterImage(filterBlobRepositioning,'inImage',imageSimulateAngle);
setParameterBoolean(filterBlobRepositioning,'monitoring',chkBlobRepositioningM
onitoring.Checked);
setParameterInteger(filterBlobRepositioning,'margin',
sbBlobRepositioningMargin.Position);
tmpI:=360; //what is going on here and next 3 lines?
if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=1 then tmpI:=720
else if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=2 then
tmpI:=3600
else if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=3 then
tmpI:=36000;
setParameterInteger(filterBlobRepositioning,'blob_ThresholdBackground',sbBlobR
epositioningBlobThreshold.Position);
setParameterInteger(filterBlobRepositioning,'blob_AreaMin',StrToInt(txtBlobRep
ositioningBlobAreaMin.Text));
setParameterInteger(filterBlobRepositioning,'blob_AreaMax',StrToInt(txtBlobRep
ositioningBlobAreaMax.Text));
setParameterInteger(filterBlobRepositioning,'vectorHistogram_anglePrecision',
tmpI);
setParameterInteger(filterBlobRepositioning,'vectorHistogram_smooth',
sbBlobRepositioningSmooth.Position);
run(filterBlobRepositioning);
chrono.Stop;
//Lost again till the next comment
image1 := getOutputImage(filterBlobRepositioning,'outImage');
imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
image.copyImageToImage(image1,imageOut);
if chkBlobRepositioningMonitoring.Checked=true then begin
images := getOutputImages(filterBlobRepositioning,'outImagesMonitoring');
if (images<>nil) and (Length(images^)>0) then begin
image2 := images^;
imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
image.copyImageToImage(image2,imageOut2);
end;
end;
//looks like text for the info box
tmpSingle:=getOutputFloat(filterBlobRepositioning,'angleToRestorOrientation');
txtBlobRepositioningComputedAngle.Text := FloatToStrF(tmpSingle,ffFixed,4,1);
tmpSingle:=calculAngleError(StrToFloat(txtBlobRepositioningSimulateAngle.Text)
,blobRepositioningLearnedAngle,getOutputFloat(filterBlobRepositioning,'angleTo
RestorOrientation'));
txtBlobRepositioningError.Text := FloatToStrF(tmpSingle,ffFixed,4,1);
end else
Here is my attempt in vb.net, with less text info. To save and load the image I use the vb.net second tutorial.
I cannot get a monitoring image and angleToRestorOrientation is always 0 or
270.
Private Sub repositioning_Click(sender As System.Object, e As
System.EventArgs) Handles repositioning.Click
Dim filterBlobRepositioning As Int32 =
Filters.createFilter("filterBlobRepositioning")
Dim imageBlob As IntPtr = Filters.image_createImageLike(imageLoaded)
setImageToSave(Filters.getOutputImage(filterBlobRepositioning, "outImage"))
'setImageToSave(Filters.getOutputImage(filterBlobRepositioning,
"outImagesMonitoring"))
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
PS
Any explanation of the filters test code, or advise on which filter to use, or
any other help would be appreciated.
Also, when trying to tanslate the filters test to vb.net, I cannot find an
equivalent for this in filtersDll.net , there is erase, and create image like
but not an exact equivalent. image.eraseOrCreateImageLike(imageOut,image1);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Rotate randomly orientated, long blobs to be horizontal in vb.net?
In my fish measuring program I can find the length and width of the fish using
BlobExplorer. However, if a fish is photographed a random angle, then my
measuring will not be accurate. I would like to use blob repositioning, blob
repositioning2, or blob balance to make blobs orientated horizontally.
So far I have been trying to use the filters test code for BlobRepositioning
but there are parts I do not understand.
if panelActif=pBlobRepositioning then begin
// to test this filter, we need to do somethings
preprocessSimulateAngle(imageIn,StrToFloat(txtBlobRepositioningSimulateAngle.T
ext)); // this function set //'imageSimulateAngle'
chrono.Start;
setParameterImage(filterBlobRepositioning,'inImage',imageSimulateAngle);
setParameterBoolean(filterBlobRepositioning,'monitoring',chkBlobRepositioningM
onitoring.Checked);
setParameterInteger(filterBlobRepositioning,'margin',
sbBlobRepositioningMargin.Position);
tmpI:=360; //what is going on here and next 3 lines?
if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=1 then tmpI:=720
else if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=2 then
tmpI:=3600
else if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=3 then
tmpI:=36000;
setParameterInteger(filterBlobRepositioning,'blob_ThresholdBackground',sbBlobR
epositioningBlobThreshold.Position);
setParameterInteger(filterBlobRepositioning,'blob_AreaMin',StrToInt(txtBlobRep
ositioningBlobAreaMin.Text));
setParameterInteger(filterBlobRepositioning,'blob_AreaMax',StrToInt(txtBlobRep
ositioningBlobAreaMax.Text));
setParameterInteger(filterBlobRepositioning,'vectorHistogram_anglePrecision',
tmpI);
setParameterInteger(filterBlobRepositioning,'vectorHistogram_smooth',
sbBlobRepositioningSmooth.Position);
run(filterBlobRepositioning);
chrono.Stop;
//Lost again till the next comment
image1 := getOutputImage(filterBlobRepositioning,'outImage');
imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
image.copyImageToImage(image1,imageOut);
if chkBlobRepositioningMonitoring.Checked=true then begin
images := getOutputImages(filterBlobRepositioning,'outImagesMonitoring');
if (images<>nil) and (Length(images^)>0) then begin
image2 := images^;
imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
image.copyImageToImage(image2,imageOut2);
end;
end;
//looks like text for the info box
tmpSingle:=getOutputFloat(filterBlobRepositioning,'angleToRestorOrientation');
txtBlobRepositioningComputedAngle.Text := FloatToStrF(tmpSingle,ffFixed,4,1);
tmpSingle:=calculAngleError(StrToFloat(txtBlobRepositioningSimulateAngle.Text)
,blobRepositioningLearnedAngle,getOutputFloat(filterBlobRepositioning,'angleTo
RestorOrientation'));
txtBlobRepositioningError.Text := FloatToStrF(tmpSingle,ffFixed,4,1);
end else
Here is my attempt in vb.net, with less text info. To save and load the image I use the vb.net second tutorial.
I cannot get a monitoring image and angleToRestorOrientation is always 0 or
270.
Private Sub repositioning_Click(sender As System.Object, e As
System.EventArgs) Handles repositioning.Click
Dim filterBlobRepositioning As Int32 =
Filters.createFilter("filterBlobRepositioning")
Dim imageBlob As IntPtr = Filters.image_createImageLike(imageLoaded)
Filters.setParameterBoolean(filterBlobRepositioning, "monitoring", True)
Filters.setParameterImage(filterBlobRepositioning, "inImage", imageLoaded)
Filters.setParameterInteger(filterBlobRepositioning, "blob_AreaMin", 40)
Filters.run(filterBlobRepositioning)
txtInfo.Items.Add(Filters.getOutputFloat(filterBlobRepositioning,
"angleToRestorOrientation").ToString)
setImageToSave(Filters.getOutputImage(filterBlobRepositioning, "outImage"))
'setImageToSave(Filters.getOutputImage(filterBlobRepositioning,
"outImagesMonitoring"))
End Sub
PS
Any explanation of the filters test code, or advise on which filter to use, or
any other help would be appreciated.
Also, when trying to tanslate the filters test to vb.net, I cannot find an
equivalent for this in filtersDll.net , there is erase, and create image like
but not an exact equivalent.
image.eraseOrCreateImageLike(imageOut,image1);
Hi Retep2
I'm sorry, but actually I have no time to investigate, and I'm not a expert in
VB.BET
Ok, thanks for replying anyway.