Skip to content

Commit

Permalink
SideScan sounded data flip option
Browse files Browse the repository at this point in the history
  • Loading branch information
risty committed Nov 16, 2017
1 parent 02187e6 commit fd899d7
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
28 changes: 27 additions & 1 deletion ConsoleLogConverter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class Options
HelpText = "Makes output file GPS coordinates anonymous. Sets Latitude and Longitude to zero.")]
public bool CoordinatesDelete { get; set; }

[Option('l', "flip", Required = false, DefaultValue = false,
HelpText = "Flip SoundedData for SidescanComposite channel.")]
public bool FlipSoundedData { get; set; }

[Option('v', "verbose", DefaultValue = true,
HelpText = "Prints all messages to standard output.")]
public bool Verbose { get; set; }
Expand Down Expand Up @@ -92,6 +96,8 @@ public string GetUsage()
text.AddPostOptionsLine("Command takes all frames from input.sl2. At the next step it subtract (use \"m\"(minus) prefix to substract and \"p\"(plus) to add value) 1.15 meters from depth value at each frame and save frames to \"csv\" format.\n\n");
text.AddPostOptionsLine("\"ConsoleLogConverter.exe -i input.sl2 -g 0:5:f -o sl2\"\n");
text.AddPostOptionsLine("Command takes all frames from input.sl2. At the next step it generate all(\"f\" option) the frames at 0th(Primary) channel from 5th(SidescanComposite) clannel and finally save frames from all input file channels to \"sl2\" format.\n\n");
text.AddPostOptionsLine("\"ConsoleLogConverter.exe -i input.sl2 -l -o sl2\"\n");
text.AddPostOptionsLine("Command takes all frames from input.sl2. At the next step it flip sounded data in frames at 5th(SidescanComposite) clannel and finally save frames to \"sl2\" format.\n\n");
return text;
}

Expand Down Expand Up @@ -342,12 +348,32 @@ static void Main(string[] args)
Console.WriteLine("Unique points at source channel(s):{0}", unicueFrameFromSourceChanels.Count);
if (forceGenerate)
Console.WriteLine("Points erased at destination channel:{0}", erasedPointsCountAtDstChannel);
Console.WriteLine("Points added to destination channel:{0}", unicueFrameFromSourceChanels.Count - dstChannelFramesPoints.Count);
Console.WriteLine("Points added to destination channel:{0}\n", unicueFrameFromSourceChanels.Count - dstChannelFramesPoints.Count);
}
}
}


#endregion

#region Flip SoundedData

if (options.FlipSoundedData)
{
if (options.Verbose)
{
Console.WriteLine("Sounded Data flip option enabled.");
Console.WriteLine("Flipping data for SidescanComposite channel ...\n");
}

foreach (var frame in data.Frames)
{
//flip soubded data for SidescanComposite channel
if (frame.ChannelType == ChannelType.SidescanComposite)
frame.SoundedData = frame.SoundedData.FlipSoundedData();
}
}

#endregion

#region Research mode consloe output
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ After that it generate 1th(Secondary) channel frames (even if frames with such c
f - if specified generate frame in destination channel even if frame with such coordinates already exist;
d - if specified generate sounded data from source frame depth value,(otherwise take sounded data from source frame).

### Flip Sidescan view
If you have confused with position of the transducer and fixed the back to the front, then you have got the reversed sidescan images.
You can fix it and flip it back.
"**ConsoleLogConverter.exe -i input.sl2 -l -o sl2**"
Command takes all frames from input.sl2. At the next step it flip sounded data in frames at 5th(SidescanComposite) clannel and finally save frames to "sl2" format.

### Research command example.
SL binary formats are closed, and there is for all values no public schema . So, you can help to project and make some research by yourself.
Expand Down
44 changes: 42 additions & 2 deletions SonarLogAPI/Lowrance/SoundedData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,46 @@ public SoundedData(byte[] data, ChannelType channelType, LinearDimension upperLi

}

/// <summary>
/// Flip <see cref="SoundedData"/> for SidescanComposite and ThreeD channels.
/// </summary>
/// <returns>Flipped <see cref="SoundedData"/>.</returns>
public SoundedData FlipSoundedData()
{
return FlipSoundedData(this);
}

/// <summary>
/// Flip <see cref="SoundedData"/> for SidescanComposite and ThreeD channels.
/// </summary>
/// <param name="soundedData">Inner <see cref="SoundedData"/>.</param>
/// <returns>Flipped <see cref="SoundedData"/>.</returns>
public static SoundedData FlipSoundedData(SoundedData soundedData)
{
switch (soundedData.ChannelType)
{
case ChannelType.Primary:
case ChannelType.Secondary:
case ChannelType.DownScan:
case ChannelType.SidescanLeft:
case ChannelType.SidescanRight:
//do nothing with sounded data of this channels
break;
case ChannelType.SidescanComposite:

//invert Data array and change upper and liwer limits values
return new SoundedData(soundedData.Data.Reverse().ToArray(), soundedData.ChannelType,
soundedData.LowerLimit * -1, soundedData.UpperLimit * -1);

case ChannelType.ThreeD:
throw new NotImplementedException();
default:
throw new ArgumentOutOfRangeException();
}

return soundedData;
}

/// <summary>
/// Create instance of <see cref="SoundedData"/> with generated <see cref="Data"/>
/// </summary>
Expand Down Expand Up @@ -98,9 +138,9 @@ public static SoundedData GenerateData(short packetSize, ChannelType channelType
if (lowerLimit.GetMeters() < 0) throw new ArgumentOutOfRangeException(nameof(lowerLimit), lowerLimit, nameof(lowerLimit)
+ "cant be less then zero for " + channelType);

var sraightArrayForSidescanComposite = GetArrayForNoiseAndBottomSurfaces((short)(packetSize/2), depth, LinearDimension.FromMeters(0), lowerLimit);
var sraightArrayForSidescanComposite = GetArrayForNoiseAndBottomSurfaces((short)(packetSize / 2), depth, LinearDimension.FromMeters(0), lowerLimit);
var fullSidescan = new byte[packetSize];
sraightArrayForSidescanComposite.Reverse().ToArray().CopyTo(fullSidescan,0);
sraightArrayForSidescanComposite.Reverse().ToArray().CopyTo(fullSidescan, 0);
sraightArrayForSidescanComposite.CopyTo(fullSidescan, packetSize / 2);
return new SoundedData(fullSidescan, channelType, upperLimit, lowerLimit);

Expand Down

0 comments on commit fd899d7

Please sign in to comment.